Re: [PHP-DB] Re: php & date manupulation functions
On Sun, Feb 16, 2003 at 08:14:57AM -0800, David Chamberlin wrote: > > >David Elliott wrote: >>try >> >>>echo date("d",$dbdate).""; >>echo date("m",$dbdate).""; >>echo date("y",$dbdate).""; >>?> > >I thought date() took a timestamp, not a string. Here's what I do: > >$timestamp = $dbdate; >echo date("d",$timestamp) >echo date("m",$timestamp) > I did this : $dob= explode('-', $aAns["dob"]); This gives me an array of $dob with yy, mm and dd. Thanks to those who replied. Peace -- Rajesh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php & date manupulation functions
David Elliott wrote: try "; echo date("m",$dbdate).""; echo date("y",$dbdate).""; ?> I thought date() took a timestamp, not a string. Here's what I do: $timestamp = $dbdate; echo date("d",$timestamp) echo date("m",$timestamp) -Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php & date manupulation functions
[EMAIL PROTECTED] (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 '-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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php