1

In my application, I am getting a finish timestamp data from server side which is in this format - 2021-02-19T06:30:58 . This is in UTC.

The requirement from client is to convert this timestamp in PST hours. The format should look like Feb 19, 2021 06:30 AM (Time should be converted to PST hours) . How to do this in Angular/Typescript.

For now this is how I am doing in my html code - {{ (finishTimeStamp | date : 'MMM d, yyyy')}} and it gives the result as Feb 19, 2021.

How can I include the time as well after converting it to PST hours.

2 Answers 2

2

Maybe try this:

{{ (finishTimeStamp | date : 'MMM d, yyyy hh:mm a' : '-0800') }}
2
  • This is showing the result as Feb 19, 2021 06:30 AM, but its in UTC. We need to convert this to PST.
    – sandeep
    Feb 21, 2021 at 15:40
  • Works now. Confirmed. Oct 25, 2021 at 0:12
0

You can add time manually using getTime(). which gets time in milliseconds.

  1. 1 minute = 60000 milliseconds
  2. 60 minutes = 60x60000
  3. 5 hours = 300x60000
  4. and so on...

Eg:

curDate=new Date();

futDate=new Date(this.curDate.getTime()+330*60000);

This will add 5 hours 30 minutes to current time.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.