0

I am trying to get this output:

2013072708410102

which is year/month/day/hour/minutes/seconds/milliseconds.

I tried this:

$getDate = date("Ymd");
$getTime = time();

echo $getDate . " " . $getTime;

I am getting this kind of output:

201307271374885743 

The year/month/day is correct. But I dont think its giving me the time format that I wanted.

How can I have this format 2013072708410102 year/month/day/hour/minutes/seconds/milliseconds?

QKWS
  • 1,069
  • 9
  • 22
  • 41
  • 1
    You can get your answer here: http://stackoverflow.com/questions/169428/php-datetime-microseconds-always-returns-0 –  Jul 27 '13 at 00:46
  • 1
    It's all in here as well: http://php.net/manual/en/function.microtime.php – Anders Jul 27 '13 at 00:47

1 Answers1

2
echo date("YmdHis").str_pad((int)((($time = microtime(1)) - (int)$time) * 1000), 3, "0", STR_PAD_LEFT);

gives: 20130727024937671 to me, what should what you expect.

date("YmdHis") gives the year/month/day/hour/minutes/seconds part.

str_pad((int)((($time = microtime(1)) - (int)$time) * 1000), 3, "0", STR_PAD_LEFT) is for the milliseconds.

bwoebi
  • 23,637
  • 5
  • 58
  • 79