Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/157740-solved-force-strtotime-to-assume-pm/
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.