0

i am working on javascript. and i have time in milliseconds. so i have to display the time in PST time Zone. i have tried for GMT. but is there any option to display the time in PST format in which the input is in milliseconds like 1671673550214. so iam trying to convert this milliseconds to time and date format of PST. same as the below code does. pleas help. Here is my tried code:

   var time = new Date().getTime();
     var date = new Date(time);
      document.write(date.toString());

i have even tried of using UTCString(), UTC() and toString(); but things is getting converted to GMT and not to PST.

Hk M
  • 73
  • 2
  • 10

2 Answers2

0

Please check this library, it has lot of functions to display and manupilate date time.

http://momentjs.com/ http://momentjs.com/docs/

Also please check following post

Moment.js: Format date in a specific timezone\

If you dont want to use external lib, see the following article

http://www.techrepublic.com/article/convert-the-local-time-to-another-time-zone-with-this-javascript/6016329

Community
  • 1
  • 1
Taimur Khan
  • 531
  • 8
  • 21
  • is there any way apart from using external js files. as my data in milliseconds is 1378740125740 – Hk M Jun 25 '13 at 10:38
  • Please see the following article http://www.techrepublic.com/article/convert-the-local-time-to-another-time-zone-with-this-javascript/6016329 – Taimur Khan Jun 25 '13 at 13:10
0

You can use timezonjs which help you to convert the time to any timezone.

https://github.com/mde/timezone-js

Miqdad Ali
  • 6,129
  • 7
  • 31
  • 50