Re: php & date manupulation functions
| From: | Fredrik de Vibe | Date: | Sat, 15 Feb 2003 15:41:33 +0000 |
| Subject: | Re: php & date manupulation functions | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25651@lists.php.net to get a copy of this message | ||
rajesh-shriram@gmx.net (Rajesh Fowkar) writes:
> Now while updating the form I want to retrieve the date and take out day,
> month and year from that date and display the correct selection in the
> combo. I could not find any function like say
>
> day($dbdate);
> month($dbdate);
> year($dbdate);
>
> Am I missing something ? Is there anyway to accomplish the above ? or I
> will have to store these three values separatly in the database rather than
> as a date.
Well, there is actually a quite good support for manipulating strings
in php. Have a look at the format of your date variable, and use
either the regexp functions or string functions like split and
explode.
Let's say your date is in a format like 'YYYY-MM-DD hh:mm:ss'. Then
somehing like
list($yy, $mon, $dd, $hh, $min, $ss) = split(" |:|-", $date);
would do the trick.
--
--Fredrik
A mathematician is a machine for converting coffee into theorems.