Re: convert yyyy/mm/dd to mm/dd/yyyy, how?

From: Date: Sun, 13 Jan 2002 19:55:20 +0000
Subject: Re: convert yyyy/mm/dd to mm/dd/yyyy, how?
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-general+get-80370@lists.php.net to get a copy of this message
Hiya, Personally, I use the following bit of code. All it does is take a 14 digit timestamp and convert it into a unix timestamp: function date($date) { //Extract the parts from the date $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $hour = substr($date, 8, 2); $min = substr($date, 10, 2); $sec = substr($date, 10, 2); //return the unix timestamp for the date passed return (gmmktime($hour, $min, $sec, $month, $day, $year)); } From then on, you can use the date function in PHP to manage the date. There are also ways to do it using the SQL command (DATE_FORMATE() I think is one), but you'll have to read the manual for into on that. At 20:56 13/01/2002 +0100, Sander Peters wrote:
Hello everybody, convert yyyy/mm/dd to mm/dd/yyyy, how? MYSQL does everything in yyyy/mm/dd. I live in the Netherlands and we are use to the format dd/mm/yyyy. What's the best way to display it as mm/dd/yyyy in a table on a query? My first idea whas to split the date up in vars in php and then print the vars in the way I like it Is this a bad idea? Or are there better sollutions? Thanx in advance for answering! -- Met vriendelijke groet / With Greetings, Sander Peters site: http://www.visionnet.nl/ email: mailto:s.peters@visionnet.nl webmail: mailto:sanderpeters@yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
// Jonathan Wright // j.d.e.wright@cs.cf.ac.uk // GCS d- s: a-- C++(+) US> P+++ L+> E> W+++ !N w !O M- V- PS+@ PE+
//    Y PGP t+ !5 X R- tv(-) b(+) DI++++> D+(++) G h-- r-- z--(++)


« previous php.general (#80370) next »