DateTime with microseconds

后端 未结 10 2124
长发绾君心
长发绾君心 2020-12-05 10:02

In my code, I\'m using DateTime objects to manipulate dates, then convert them to timestamp in order to save them in some JSON files.

For some reasons,

10条回答
  •  天涯浪人
    2020-12-05 10:32

    since I resolved my issue i want to share it with You. Php71+ have microsecconds accuracy, if You want to convert it into nano accuracy just multiply it by 1000 (10^3).

    $nsTimestamp = (int) (new \DateTime())->getTimestamp() * 1000
    

提交回复
热议问题