get the ISO 8601 with seconds.decimal-fraction-of-second date in php?

前端 未结 5 1024
遇见更好的自我
遇见更好的自我 2020-12-16 19:26

I echo this :

  php> echo date(\"Y-m-d\\TH:i:s\");
      2011-05-27T11:21:23

How can do with date function to get this date format:

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 19:35

    If parsing the string returned by microtime makes you vomit in your mouth, and you don't want multiple distinct timestamps munged together into your output, you can do this:

    $unow = microtime(true);
    sprintf("%s.%06d%s", date("Y-m-d\TH:i:s", $unow), ($unow - floor($unow))*1e6, date("P", $unow));
    

提交回复
热议问题