I must convert the server current time to this format:
2016-03-23T05:24:25.590000
I think this is an ISO 8601 (even if I don't understand what are the final numbers, supposedly microseconds).
How can I do? Any help is welcome
I must convert the server current time to this format:
2016-03-23T05:24:25.590000
I think this is an ISO 8601 (even if I don't understand what are the final numbers, supposedly microseconds).
How can I do? Any help is welcome
The final numbers are the microseconds. It is easy to output a given DateTime object $d
in this format:
echo $d->format('Y-m-d\TH:i:s.u');
It is not so easy, to get the current timestamp including microseconds, because constructing it with now
only gets whole seconds. You could go this way and append the microseconds manually:
echo date('Y-m-d\TH:i:s') . substr((string) microtime(), 1, 7);
// 2016-03-23T14:55:25.535678
See doc for microtime()
and DateTime
.