Dear All,
I have already attempted searching for this issue but came up with nothing.
I am extracting records from MySQL, I have the dates in the date field in the format dd/mm/yr, which was enter from a normal registration form.
I would like to display the 'yr' (year only) from the dd/mm/yr field.
eg: Name/ Address / Year instead of Name/Address/Date
Can you assist in helping me solve this problem please.
Regards
Dave
Separate year from date format
Moderator: General Moderators
Re: Separate year from date format
Code: Select all
$timer_given = '02/06/2006';
$my_time = strtotime($timer_given);
$my_date = date('y',$my_time);
echo $my_date; //gives you the required year
//this gives you as 06
//incase you want it as 2006, replace 'y' with 'Y'
Re: Separate year from date format
Thanks susrisha,
I'll try this.
Best Regards
Dave
I'll try this.
Best Regards
Dave