Convert current server time to ISO 8601

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

Answers


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.


Need Your Help

Firefox 13.0.1 cannot correctly determine content type of docx file

.net file-upload cross-browser mime-types

My MVC-3 application has a file upload feature. The file content and content type are saved in database so that while trying to download, the correct file can be reencrypted.

GIT: How to see pulled/pushed changes in origin

git

I've just started using Git (previously Subversion). I'm having real problems getting my head round being unable to see pushed or pulled changes in the original repository. My 'architecture' is thi...