Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript timestamp limit to the last 8 characters

Tags:

javascript

It is simple enough to get timestamp:

new Date().getTime();

but I need to limit the timestamp to 8 characters, and these need to be the last 8 rather than the first 8.

for example:

new Date().getTime(); // returns: 1234567891234

I need it to return:

67891234

can you help?

Thanks in advance

like image 926
user1242345 Avatar asked May 12 '26 00:05

user1242345


1 Answers

new Date().getTime().toString().substr(-8);
like image 164
PCasagrande Avatar answered May 14 '26 14:05

PCasagrande