开发者

Convert Created Time using Javascript FQL Facebook

开发者 https://www.devze.com 2023-03-10 05:00 出处:网络
I am using Facebook FQL to get photos and the time when they were created. The problem is am getting the created time as some long integer value e.g. 1306776492.

I am using Facebook FQL to get photos and the time when they were created. The problem is am getting the created time as some long integer value e.g. 1306776492.

Now I am unable to convert it to proper d开发者_C百科ate time using javascript.

Can anyone point me in the right direction


You can set a Date objects time with the setTime method.

var d = new Date();
d.setTime(1306776492*1000);
document.write(d);

returns

Mon May 30 2011 20:28:12 GMT+0300 (FLE Daylight Time)

http://jsfiddle.net/niklasvh/ANRcm/

If you want the date to be printed in a different format, just have a look at the other methods available for Date()

0

精彩评论

暂无评论...
验证码 换一张
取 消