Home > Mobile >  Which time stamp format is this 1651928421543667000
Which time stamp format is this 1651928421543667000

Time:05-09

I'm using an API and it returns timestamp as 1651928421543667000, I can't find the supported format I have tried using

strtotime()
datetime() 
strftime()

in PHP any help? Thanks!

CodePudding user response:

It's a timestamp in nanoseconds. Devs need ns precision for some low-level tasks with I/O, RAM, radio signals and etc. You can get the same value in PHP by using a command such as echo system('date %s%N');. You can also convert ns into ms or s by using basics of metric system where nano indicates 10^-9.

CodePudding user response:

So the output is a UNIX-Timestamp format. If you want to convert it to a regular datetime format, use the following code. However, you have to convert it to seconds first by dividing the time by 10^9 as @mardubbles pointed out.

$time = time();    
date("d F Y H:i:s", $time);
  • Related