Re: Dates

From: Date: Fri, 03 Oct 2003 18:44:42 +0000
Subject: Re: Dates
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164946@lists.php.net to get a copy of this message
Also, an option is to have that SQL field set as date. With postgres, I can insert 09-12-1967 and the sql server auto converts it to 1967-09-12 upon saving into date field. However, another way is.. <? $date="09-12-1967"; $dARR=explode("-", $date); $tmon=$dARR[0]; $tday=$dARR[1]; $tyr=$dARR[2]; $newdate="$tyr-$tmon-$tday"; ?> Jay Blanchard wrote:
[snip] Ok, Mayve I need to be a little clear, I under the link below as showing dates. What I need to know how can I take the input of 09-12-1967 and have enter into a mysql data using php as 1967-09-12? Because everything that is past from my form to mysql is not the way it was enter. Would I need to create three fields month, day, year, then take those three into yyyy-mm-dd? If so how? [/snip] Aha. $theOldDate = 09-12-1967; $theNewDate = substr($theOldDate, 6, 4)."-".substr($theOldDate, 0, 2)."-".substr($theOldDate, 3, 2); echo $theNewDate;


« previous php.general (#164946) next »