Jump to content

Recommended Posts

DD-MM-YYYY (01-04-2010)

MM-DD-YYYY (04-01-2010)

 

+ Other ways of formating date and time.

 

I believe strtotime() would give those dates a different timestamp as the format isn't defined.

 

How could I work around it? It's part of form validation.. so by this point, nothing is inserted into the database.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/202116-strtotime-questions/
Share on other sites

well what are you ultimately putting into your database, a timestamp of the date the user enters in?  Sure, you can use mktime but if you already have the fields separated and know which values are for what, you can use strtotime just the same..., since you control the format being handed to it...

 

edit:

strtime attempts to parse the string, and it recognizes a lot of formats, but if you are unsure how to format it, yyyy-mm-dd works.

Link to comment
https://forums.phpfreaks.com/topic/202116-strtotime-questions/#findComment-1059857
Share on other sites

Well originally it was inputted as readable format.. but I'm changing functionality so I'm inputting everything in Timestamps.

but if you are unsure how to format it, yyyy-mm-dd works.

Sure, but how would it know the difference between 01-04-2010 & 04-01-2010. Wouldn't it just choose the first format and make do with it, I'll use the YYYY-MM-DD format though. Would be nice for a bit of explaining. I don't think PHP.net mentions anything about it.

Link to comment
https://forums.phpfreaks.com/topic/202116-strtotime-questions/#findComment-1059860
Share on other sites

Well originally it was inputted as readable format.. but I'm changing functionality so I'm inputting everything in Timestamps.

but if you are unsure how to format it, yyyy-mm-dd works.

Sure, but how would it know the difference between 01-04-2010 & 04-01-2010. Wouldn't it just choose the first format and make do with it, I'll use the YYYY-MM-DD format though. Would be nice for a bit of explaining. I don't think PHP.net mentions anything about it.

 

In short, it can't parse everything, due to some formats being ambiguous.  See the link Dan provided for details.

Link to comment
https://forums.phpfreaks.com/topic/202116-strtotime-questions/#findComment-1060243
Share on other sites

In his defense, that page was added this Sunday, so it's not available on the regular mirrors yet. The regular mirrors update their copy of the manual every Friday while the docs box updates four times each day.

 

http://svn.php.net/viewvc?view=revision&revision=299403

Link to comment
https://forums.phpfreaks.com/topic/202116-strtotime-questions/#findComment-1060265
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.