1

I am getting a datetime that is in UTC. I like the result to show the datetime locally in the following format:

    September 18th 2013, 7:07:00 PM

Is there a function that can come close to this..

I tried the following but not the result I was looking for:

     var dt = new Date(date + " UTC");
     return dt.toString(); 
Nate Pet
  • 41,226
  • 116
  • 259
  • 398

2 Answers2

0

Different variations of this question have been asked many times before. Without knowing your input datatype for "date" the question is a little unclear. Please refer to this post, it should answer your question on formatting dates.

Where can I find documentation on formatting a date in JavaScript?

Community
  • 1
  • 1
Jwit
  • 176
  • 6
0

You can use the moment.js for this:

moment().format('LLL');  // Closest output will be like this :- October 9 2013 11:17 PM
Rahul Tripathi
  • 161,154
  • 30
  • 262
  • 319