Convert UNIX timestamp in jQuery

前端 未结 3 1399
不知归路
不知归路 2021-01-19 00:27

Well, I fetch timestamp from my table using a php page with getJSON. Here is the structure.

main.php --> using getJSON (abc.php) --> value from my table

Is t

3条回答
  •  爱一瞬间的悲伤
    2021-01-19 01:24

    The Unix timestamp is the number of seconds elapsed since 1970 (epoch). You would need to convert that to a date object in JS:

    var date = new Date(unixTimestamp*1000); // *1000 because of date takes milliseconds
    

    Once you have the date object, you can use any of the techniques mentioned in the following post: How to format a JavaScript date

提交回复
热议问题