I'm trying to determine whether a string that represents the date and time, given in a JSON Twitter feed is within a range of timestamp columns in MySQL.
Here's the example string:
'Sat, 31 Oct 2009 23:48:37 +0000',
The +0000
according to the API ( created_at
) indicates it is indeed UTC
. Now, I'm using strtotime
and date
just to confirm the time. With:
$t = 'Sat, 31 Oct 2009 23:48:37 +0000';
$timestamp = strtotime($t);
echo date('M d Y H:m:s', $timestamp);
I get Oct 31 2009 19:10:37
. If I remove the +0000
I get Oct 31 2009 23:10:37
. So the difference between having +0000
and not having it is 4 hours. I'm guessing because of my local timezone ( Maryland, USA = America/New_York
) and that differing from the UTC obviously.
I'm not quite sure if I should be stripping the +0000
or using it when trying to determine if this timestamp is within the range of the two timestamps stored in my database, which are 2009-10-30 23:16:38
and 2009-11-25 12:00:00
. I feel silly and a bit confused now, when I populated these timestamps the YYYY-MM-DD H:M:S came from a Javascript date time picker, an example format is 10/31/2009 11:40 am
and I use STR_TO_DATE like so:
STR_TO_DATE("10/31/2009 11:40 am", "%m/%d/%Y %l:%i %p")'),
Should I leave the +0000
or strip it? Mentally taps out