MobileDev
MobileDev

Reputation: 46

Which time stamp format is this 1651928421543667000

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!

Upvotes: 0

Views: 791

Answers (2)

Varun Jain
Varun Jain

Reputation: 95

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);

Upvotes: 0

user1597430
user1597430

Reputation: 1146

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.

Upvotes: 2

Related Questions