Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert date format.

Status
Not open for further replies.

seahorse123

Programmer
Jul 25, 2005
39
US
I want to convert the string($date) from "Apr 5 2003 12:00AM" to "04/05/03", what function I should use, I tried:
Code:
date('m/d/Y',$date);
$date="Apr 5 2003 12:00AM"
but it returns: 12/31/1969

anyone can help? thanks.

 
The date() function takes an integer for an argument. You have to convert the string to an integer by using strtotime(). See
Code:
$date='Apr 5 2003 12:00AM';
echo date('m/d/Y',[b][red]strtotime([/red][/b]$date[b][red])[/red][/b]);
Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top