note 87073 modified in function.date by thiago

From: Date: Tue, 18 Nov 2008 19:54:51 +0000
Subject: note 87073 modified in function.date by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146658@lists.php.net to get a copy of this message
Just in case anyone else is looking for an easy-to-find equivalent for W3C Datetime or date("c") in a previous version of php, here's one I did. Hope it helps someone. <?php function w3cDate($time=NULL) { if (empty($time)) $time = time(); $offset = date("O",$time); return date("Y-m-d\TH:i:s",$time).substr($offset,0,3).":".substr($offset,-2); } ?> Examples: echo w3cDate(); //2008-11-18T12:15:18-07:00 echo w3cDate(mktime(2,3,4,5,6,2007)); //2007-05-06T02:03:04-06:00 --was-- Just in case anyone else is looking for an easy-to-find equivalent for W3C Datetime or date("c") in a previous version of php, here's one I did. Hope it helps someone. function w3cDate($time=NULL) { if (empty($time)) $time = time(); $offset = date("O",$time); return date("Y-m-d\TH:i:s",$time).substr($offset,0,3).":".substr($offset,-2); } Examples: echo w3cDate(); //2008-11-18T12:15:18-07:00 echo w3cDate(mktime(2,3,4,5,6,2007)); //2007-05-06T02:03:04-06:00 http://php.net/manual/en/function.date.php

« previous php.notes (#146658) next »