开发者

Converting YYYY-MM-DD to unix timestamp in Javascript

开发者 https://www.devze.com 2023-03-10 13:25 出处:网络
I need to convert a date in format eg. 2011-01-02 to a unix timestamp in JavaScript but do not exactly know how to accomplish it. I can get the current timestamp using the following functions Math.rou

I need to convert a date in format eg. 2011-01-02 to a unix timestamp in JavaScript but do not exactly know how to accomplish it. I can get the current timestamp using the following functions Math.round((new Date()).getTime() / 1000); but do not know how to convert the g开发者_Python百科iven date to a unix timestamp?


You can write new Date("2011-01-02").getTime() / 1000

0

精彩评论

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