Link to home
Start Free TrialLog in
Avatar of dbnewbie
dbnewbie

asked on

PHP GetYear, GetMonth, & GetDay Functions

Does PHP have GetYear, GetMonth, &  GetDay Functions? For example:

$Date = 2003-3-3;
$Year = GetYear($Date); // yields 2003

and so on . . .
Avatar of laurly
laurly
Flag of Denmark image

no but you can use getdate
http://www.php.net/manual/en/function.getdate.php

$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
echo "$month $mday, $year";


laurly
Avatar of dbnewbie
dbnewbie

ASKER

Laurly,

Your assumption is that I am going to obtain the date from the system. Actually, I am going to get it from a database. Also, it will only contain date information (no time). Will what your suggesting work with that? The field type in the database is Date/Time.
ASKER CERTIFIED SOLUTION
Avatar of VGR
VGR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note that a DATETIME containing no time part is supposed to be called a DATE field :D