Jump to content

[SOLVED] Force strtotime to assume PM?


doof

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

Archived

This topic is now archived and is closed to further replies.

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