note 34685 added to function.explode

From: Date: Mon, 04 Aug 2003 04:46:05 +0000
Subject: note 34685 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-53286@lists.php.net to get a copy of this message
So, I had a little problem. I've got some dates, in mysql date format, for example, 1969-12-31. I wanted them to be in US format, for example, 12/31/1969. So you know what I did? I wrote a little script, using explode(), that will do it for you. My PHP might be a little sloppy for your standards, but here she is: function convert_date($var) { $elements = explode("-", $var); $elements[0] = $year; $elements[1] = $month; $elements[2] = $day; $date = $month . "/" . $day . "/" . $year; return $date; } and there you have it. :) ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34685 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34685&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34685&report=yes

« previous php.notes (#53286) next »