Re: Is there a PHP equivalent of DATE_FORMAT ?

From: Date: Wed, 21 Feb 2001 21:52:38 +0000
Subject: Re: Is there a PHP equivalent of DATE_FORMAT ?
Groups: php.db 
Request: Send a blank email to php-db+get-6840@lists.php.net to get a copy of this message
Timothy Wright wrote: >... so echo date("Y-n-j") would give me the output in the right format, but >I need to convert the input to a valid timestamp first. You can use parse out the year, month and day and then use the mktime function - the dates I use are dd/mm/yy format: /*Make an array of the string TransDate using the / character as the seperator*/ $Date_array = explode("/", $TransDate); /*If the year is before 60 then assume we are in 2000 - look out in 2061 ! */ If ((int)$Date_array[2] <60) { $Date_array[2] = "20". $Date_array[2]; } elseif ((int)$Date_array[2] >59 AND (int)$Date_array[2] <100) { $Date_array[2] = "19". $Date_array[2]; } /*Make a unix time stamp out of the array elements */ $TransDate = mktime(0,0,0,$Date_array[1],$Date_array[0],$Date_array[2]); Phil

« previous php.db (#6840) next »