some time ago i find out that i can use this to convert the time from this 1273185387format:
var myObj = $.parseJSON('{"date_created":"1273185387"}'),
myDate = new Date(1000*myObj.date_created);
console.log(myDate.toString());
console.log(myDate.toLocaleString());
console.log(myDate.toUTCString());
and the results are:
Thu May 06 2010 15:36:27 GMT-0700 (Pacific Daylight Time)
Thursday, May 06, 2010 3:36:27 PM
Thu, 06 May 2010 22:36:27 GMT
what if i want to strip the date somehow to show the mm-dd-yyyy or only the time?
any ideas?
thanks
Here’s a nice article that gives an overview on Working With Dates
Plug for using Date.js
You may not be in the market for an entire Javascript library, but Date.js is amazing! It adds tons of intuitive functions that make working with dates in javascript very easy.
It provides a
.toString()method which allows you to specify the format easily. Here’s some examples: