在Angular中将UTC时间戳转换为PST

时间:2021-02-21 15:31:18

标签: angular typescript angular6 typescript2.0

在我的应用程序中,我从服务器端获取了这种格式的完成时间戳数据 - from tkinter import * window=Tk() window.geometry("1366x768+1+1") def toggle_graph_visibility(): graph_state_chosen=show_graph_checkbox_value.get() if graph_state_chosen==0: frame.place_forget() else: frame.place(x=1025,y=165) score_pixel = PhotoImage(width=300, height=430) show_graph_checkbox_value = IntVar(value=1) frame=Frame(window,width=300,height=430) graph_canvas = Canvas(frame, width = 300, height = 430,scrollregion=(0,0,300,300)) my_canvas=graph_canvas.create_image(20, 20, anchor=NW, image=score_pixel) vbar=Scrollbar(frame,orient=VERTICAL) vbar.config(command=graph_canvas.yview) vbar.pack(side=RIGHT,fill=Y) graph_canvas.config(yscrollcommand=vbar.set) graph_canvas.pack(side=LEFT,expand=True,fill=BOTH) frame.place(x=1025,y=165) Checkbutton(window, text="show graph",variable=show_graph_checkbox_value,command=toggle_graph_visibility).place(x=900,y=165) window.mainloop() 。这是 UTC。

客户要求以 PST 小时为单位转换此时间戳。格式应类似于 2021-02-19T06:30:58(时间应转换为 PST 小时)。如何在 Angular/Typescript 中执行此操作。

现在这就是我在我的 html 代码中所做的 - Feb 19, 2021 06:30 AM 并且它给出的结果为 {{ (finishTimeStamp | date : 'MMM d, yyyy')}}

如何在将时间转换为 PST 小时数后也包括时间。

1 个答案:

答案 0 :(得分:2)

也许试试这个:

{{ (finishTimeStamp | date : 'MMM d, yyyy hh:mm a' : '-0800') }}