So I’ve got a text input that get’s date & time in this format:
09/06/2010 21:08 (meaning September)
I’m using date_parse_from_format('m/d/Y H:i', $stringtoparse); (someone tell me if I’m incorrect here)
That function returns an associative array with indexes like “year” or “day” or “hour”.
The original text that was sent in needs to be treated as though it were in a certain timezone. It’ll always be EST, but I’m just having troubles figuring out how to adjust for the timezone anyway.
Basically, in the end, there will be two datetimes in the database (a start time and an end time). I need to know if the current time is in between those two times. I know once I have a final timestamp I can just use:
$startdate < now() < $enddate or something like such (of course now needs to be in the format of “EST”, but I need to be sure timezones are correct first. How do I do this?
You should store all dates in single timezone, we have chosen UTC for DB storage and are converting it to user’s timezone on render.
You are not incorrect, however I recommend using
DateTime::createFromFormatinstead.