PHP date questions (GetYear,GetMonth,GetDay)?

Does PHP have functions for GetYear, GetMonth, & GetDay

example:
$Date = 2009-8-7;
$Year = GetYear($Date);
print $Year;//print 2009
and so on . . .

Your rating: None Average: 1 (1 vote)

Replies

No

No but it wouldn't be hard to add functions that do the same thing.

Although if you have the date in a known string format like 2009-8-7 better off just exploding it

$date = explode("-",'2009-8-7');

$date[0] will have the year
$date[1] will have (is that month or day?
$date[2] will have (is that month or day?
Working with unknown dates from strings can be inaccurate unless you are sure that the date is how you would expect it.

Your rating: None Average: 5 (1 vote)

Post new comment

 
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><code>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.