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
  • 44,246
  • 124
  • 269
  • 414

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
  • 156
  • 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
  • 168,305
  • 31
  • 280
  • 331