Hi All,
This is probably an easy one, but I just need to extract the numeric value for the month, day, and year of a MySQL Date/Time field. I'm an ASP convert, and in ASP you could simply use month(date), day(date), or year(date). Are there similar functions in PHP? I did google & search the php online manual and came up dry.
Thanks in advance!
Extracting month, day, year from a date field in MySQL DB
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
There are multiple ways. MySQL can perform the such extractions via the EXTRACT() function, or you can use PHP's functions. The function to use from PHP depends on how the information from MySQL is returned. If a DATE/DATETIME type, explode() can be used to break the resultant string apart into array elements; When using a Unix timestamp compatible field (INT), the date() function can be used.
-
smartknightinc
- Forum Newbie
- Posts: 4
- Joined: Wed Nov 02, 2005 11:45 pm
solution
hi,
Use date_format() function of mysql

Thanks & Regards
harry
Use date_format() function of mysql
Thanks & Regards
harry