date format<

liunx

Guest
hi can anyone help me format a date?

I have it as a string in the form 16/05/00 and want really to put it into a time stamp using the strtotime function

BUT i cant get the right result!!

cheersI have found the problem cheersSee RFC 3339 for acceptable date formats to use on the Internet.

Different countries previously used different formats. Under the old scheme today is: 10/12/03 in Europe, 12/10/03 in the US, and 03/12/10 in Asia.

Since the Year 2000 you are advised to write all dates using all four digits for the year, and to avoid the 10/12/2003 (dd/mm/yyyy) -- 12/10/2003 (mm/dd/yyyy) UK/US date format ambiguity, by using the YYYY-MM-DD date format instead. This works simply because no-one uses yyyy-dd-mm anywhere at all.I havent found the problem I am getting the wrong date back

$st='26/05/77';

print $st . "<br />";

$time=strtotime($st);
print(date(" d / m / y",$time));


the results are as follows

26/05/77
05 / 02 / 79

is there something i should put in the strtotime method to let it know what for the string $st is in.

I have exploded it and i am getting the right results but i would like to know for future reference if there is an easy waywaht is teh purpose of this

$st='26/05/77';

print $st . "<br />";

$time=strtotime($st);
print(date(" d / m / y",$time));


if you are just going to echo it back out then leave it as is. if you want you can start storing time instead fo date. then you don't have to worry about it.

you can always exploded the $st date and use mktime() to get it I guess.its cause it gets displayed in different ways around the site, and i want just the timestamp to store in the DB but i get the date in string form from a XML file.

I was just showing an example of how it was not working.


Cheers for the helpWhat format is the date in the XML code?

It should be the YYYY-MM-DD format as defined in ISO 8601 / RFC 3339. If it isn't then your XML data isn't valid.no its inbeded in a description which is a long string.

Its actually rss feed that gives me reviews of things but all the review information is in one element so i have to break it into its components
 
Back
Top