Re: php & date manupulation functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux