Reading User-input Dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
luo ge
Forum Newbie
Posts: 2
Joined: Thu Apr 10, 2008 7:44 pm

Reading User-input Dates

Post by luo ge »

:?: I am a fairly new PHP beginner. Is there an easy way to ensure that a date entered by a user in a non-American setting as "1/5/2008" will be correctly interpreted by PHP (strtotime) as "1 May 2008", and not changed to "5 January 2008"?
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Re: Reading User-input Dates

Post by Rovas »

Simple you put the form in the american way: Month select, Day select, Year select or text that indicates that the date must be inputed in that way. Saves you a lot of trouble for verifying the data inputed, using substring function to modify the inputed string.
luo ge
Forum Newbie
Posts: 2
Joined: Thu Apr 10, 2008 7:44 pm

Re: Reading User-input Dates

Post by luo ge »

So you are saying that there is not an easy way to allow people to enter the date in the manner that they are accustomed to, and are therefore less likely to make an error with, and which also seems somewhat more logical than the "start-in-the middle" American way.
User avatar
Popcorn
Forum Commoner
Posts: 55
Joined: Fri Feb 21, 2003 5:19 am

Re: Reading User-input Dates

Post by Popcorn »

Post Reply