Home > PHP, Snippets of Code > PHP time function, ISO 8601

PHP time function, ISO 8601

This is a PHP time function according to the output format specified by ISO 8601 (yyyy-mm-dd hh:mm:ss):

function time_iso8601() {
$timearray = getdate(time());
return sprintf("%04d-%02d-%02d %02d:%02d:%02d", $timearray['year'], $timearray['mon'], $timearray['mday'], $timearray['hours'], $timearray['minutes'], $timearray['seconds']);

Categories: PHP, Snippets of Code Tags: , , ,
  1. Anonymous
    2013/10/11 at 2:18 pm

    Great function. Very handy and I use a lot in all my developments

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: