Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP generating 13-digit timestamp like mktime [duplicate]

Tags:

php

timestamp

Possible Duplicate:
php get microtime from date string

For a specific purpose, I need to get the 13-digit timestamp for a date/time, but I couldn't find a solution for this.

Like mktime in PHP, we can get a 10-digit timestamp

echo mktime($hour, $minute, $second, $month, $day, $year);

This outputs something like 1346689283.

So what about the 13-digit timestamp? Is PHP itself capable of generating such timestamps?

like image 465
user1643156 Avatar asked Dec 08 '22 21:12

user1643156


2 Answers

You are looking for microtime()

http://php.net/microtime

If you want to create microtime from a specific date, just add 000. Because in the end, the microtime is only 1 second.

like image 175
Rene Pot Avatar answered Dec 11 '22 11:12

Rene Pot


Make milliseconds:

$milliseconds = round(microtime(true) * 1000);
echo date("Y-m-d",($milliseconds/1000));
like image 44
Mihai Iorga Avatar answered Dec 11 '22 09:12

Mihai Iorga