doof Posted May 11, 2009 Share Posted May 11, 2009 I'm kind of new to PHP so I apologize if this is a stupid question. I have a form that accepts user input. One of the fields that needs to be filled out is the time that a meeting took place. Is there anyway that, if the user doesn't specify am or pm, to assume PM? So for instance, if they input "7:30", strtotime correctly interprets that as 7:30 AM. I'd like to insure that in this case, I wind up with 7:30 PM. I thought about just taking any AM value and adding 12 hours to it to force it to PM, because I can be pretty much guaranteed that all of the meetings will take place at night, but with this approach, there will be no way for the user to ever enter an AM meeting, if, for whatever reason, one ever took place. So is there some way to do this? Some complicated regex perhaps that can determine if am, a.m., AM, or A.M. was entered? Or is there a better way? Quote Link to comment https://forums.phpfreaks.com/topic/157740-solved-force-strtotime-to-assume-pm/ Share on other sites More sharing options...
gevans Posted May 11, 2009 Share Posted May 11, 2009 Why don't you get them to enter using a 24 hours clock style 19:30 Or use a drop down after the input where they have to chose am or pm Quote Link to comment https://forums.phpfreaks.com/topic/157740-solved-force-strtotime-to-assume-pm/#findComment-831962 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 date Check out the options for that function. It should have one for displaying AM and PM so you shouldn't have to worry about it. Quote Link to comment https://forums.phpfreaks.com/topic/157740-solved-force-strtotime-to-assume-pm/#findComment-831994 Share on other sites More sharing options...
doof Posted May 12, 2009 Author Share Posted May 12, 2009 Or use a drop down after the input where they have to chose am or pm That's such a simply perfect solution that I'm ashamed I never thought of it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/157740-solved-force-strtotime-to-assume-pm/#findComment-832121 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.