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
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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.