hello,
I'm trying to get the "day" out of a datetime, eg. 2010-06-21 10:00:00... where I want to get a variable containing "21".
As I'm new to PHP I can't get this done, although it seems to be a quite easy function, not?
function get_day($givendatetime) {
$getday = ; // can someone help me with the code i have to put in this line?
return $getday;
}
Any help is very much appreciated!
grtz,
F.
get day out of datetime
Moderator: General Moderators
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Re: get day out of datetime
You may want to use some RegEx. Hint: google for "MySQL date to PHP".
Or, the quick and dirty way:
Or, the quick and dirty way:
Code: Select all
$date = explode(' ', $date);
$day = end(explode('-', $date[0]));
Re: get day out of datetime
Are you getting this date from MySQL? Use the DATE_FORMAT function.