Welcome Guest, Not a member yet? Register   Sign In
Converting a user submitted date to GMT

One thing to be wary of is the format of the date string being supplied. strtotime behaves differently depending on whether '-' or '/' is used in the date string, and can potentially cause issues getting the accurate time. I ran into this since I've done a lot of work for a client out of Manchester, UK, but I live in USA. From the PHP manual:

Quote:Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.

strtotime does support parsing out the timezone as part of the string, so it might work to ensure the timezone string is part of the string passed to the strtotime() function, but would need testing. For the project that I had problems on, we knew that all users would be UK area so I didn't have to explore quite that deep and ended up using DateTime::createFromFormat() where possible.

Messages In This Thread
RE: Converting a user submitted date to GMT - by kilishan - 07-06-2015, 09:41 AM

Theme © iAndrew 2016 - Forum software by © MyBB