Jump to content

strtotime different dates


alecks

Recommended Posts

just a quick question: the function strtotime converts strings formatted like dates into unix timestamps. This is great, but how do I tell it to only expect one format? for example: the date 1-08-2008 could be interpreted as January 8th, 2008, or August 1st, 2008. I want it mm-dd-yyyy.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/85247-strtotime-different-dates/
Share on other sites

just a quick question: the function strtotime converts strings formatted like dates into unix timestamps. This is great, but how do I tell it to only expect one format? for example: the date 1-08-2008 could be interpreted as January 8th, 2008, or August 1st, 2008. I want it mm-dd-yyyy.

 

thanks

If you mean to check if the user has entered in a certain format, you have to use preg_match(), ereg, or eregi and use RegExp.

I don't mean that at all, because that wouldn't help :/

I want strtotime to assume that any date strings given to it are in a certain format, for example m-d-yyyy. I want this because sometimes when a date is given to it it will think that it is in a different format, d-m-yyyy for example. For example, if I gave it the m-d-yyyy date 1-8-2008, it will give me back a timestamp for 8-1-2008, which is not what I want. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.