note 30370 added to function.substr

From: Date: Sat, 15 Mar 2003 18:15:04 +0000
Subject: note 30370 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-45360@lists.php.net to get a copy of this message
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! -- http://www.php.net/manual/en/function.substr.php http://master.php.net/manage/user-notes.php?action=edit+30370 http://master.php.net/manage/user-notes.php?action=delete+30370 http://master.php.net/manage/user-notes.php?action=reject+30370

« previous php.notes (#45360) next »