note 30370 deleted from function.substr by aidan

From: Date: Sat, 03 Jul 2004 07:46:24 +0000
Subject: note 30370 deleted from function.substr by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72372@lists.php.net to get a copy of this message
Note Submitter: paul@santasoft.com ---- Been wondering how to convert those pesky YYYYMMDD dates to their individual values quickly and easily? Try this: $yyyymmdd = "20030711"; list($year,$month,$day) = array(substr($yyyymmdd,0,4), substr($yyyymmdd,4,2), substr($yyyymmdd,6,2)); echo($year." ... ".$month." ... ".$day); Voila! The one-liner conversion (should be one line, it may have broken it over two). Echoes this: 2003 ... 07 ... 11 This handy language construct reminder can handle dates through the year 9999. Minimize your code! Have fun!

« previous php.notes (#72372) next »