admin管理员组文章数量:1193728
Hi this is incredibly simple i cant believe im asking this.
I have tried the following:
Moment.now()
Date.now()
new Date().valueOf()
And various other tricks found in other stack overflow questions
They all give me the time in microseconds.
e.g
1543409290654
which is 09/10/50878 @ 10:57am (UTC)
Im aware i could divide by 1000 but surely there is an api in javascript to get the unix timestamp in milliseconds.
Ive have seen this in chrome and react native
EDIT:
So i realise my stupidity i was putting the unix timestamp into a website that renders it as an ISO date but it was expecting seconds which is why i thought my dates were coming in as milliseconds
Hi this is incredibly simple i cant believe im asking this.
I have tried the following:
Moment.now()
Date.now()
new Date().valueOf()
And various other tricks found in other stack overflow questions
They all give me the time in microseconds.
e.g
1543409290654
which is 09/10/50878 @ 10:57am (UTC)
Im aware i could divide by 1000 but surely there is an api in javascript to get the unix timestamp in milliseconds.
Ive have seen this in chrome and react native
EDIT:
So i realise my stupidity i was putting the unix timestamp into a website that renders it as an ISO date but it was expecting seconds which is why i thought my dates were coming in as milliseconds
Share Improve this question edited Nov 28, 2018 at 13:14 Luke De Feo asked Nov 28, 2018 at 12:52 Luke De FeoLuke De Feo 2,1654 gold badges24 silver badges41 bronze badges 7 | Show 2 more comments2 Answers
Reset to default 16Date.now() returns the number of milliseconds since midnight January 1, 1970
There is no native javascript to format time into unix-timestamp.
I found this useful
var today = Math.round((new Date()).getTime() / 1000);
console.log(today);
本文标签: react nativeGet current unix time in milliseconds in javascriptStack Overflow
版权声明:本文标题:react native - Get current unix time in milliseconds in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738410754a2085310.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Im aware i could divide by 1000
There is your answer, are you having trouble dividing by 1000?. – Keith Commented Nov 28, 2018 at 12:58ITS NOT working, please read my question
I think everyone appears to have read the question, but you seem to be ignoring them. Your still not dividing by 1000, and wonder why it's wrong.(new Date().getTime() / 1000 | 0)
ps. Avoid ITS NOT working, it's not helpful. – Keith Commented Nov 28, 2018 at 13:06