On 29 June 2011 17:09, Brian Dunning <br...@briandunning.com> wrote:
> Help. I'm using PayPal's API to get a report of all the yesterday's 
> transactions. I'm in California, and I define "yesterday" as California's 
> yesterday, midnight to midnight.
>
> PayPal wants the STARTDATE and ENDDATE provided in UTC/GMT. I'm building and 
> testing my report using this:
>
> $start = gmdate('Y-m-d\TH:i:s.00\Z', strtotime("yesterday 00:00:00"));
> $end = gmdate('Y-m-d\TH:i:s.00\Z', strtotime("yesterday 23:59:59"));
>
> which produces:
>
> 2011-06-28T07:00:00.00Z
> 2011-06-29T06:59:59.00Z
>
> I think this is right, since it's 7 hours off California time, but I just 
> need someone to double check my spinning head. Will this give me the PayPal 
> transactions that arrived during California's yesterday, or do I need to 
> change something?
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Something like this ?

<?php
$o_Start = new DateTime('00:00:00.000', $o_CalifTZ = new
DateTimeZone('America/Los_Angeles'));
$o_End   = new DateTime('23:59:59.999', $o_CalifTZ);
echo date('Y-m-d\TH:i:s.00\Z', $o_Start->getTimestamp()), ' to ',
date('Y-m-d\TH:i:s.99\Z', $o_End->getTimestamp()), PHP_EOL;


And UTC is not the same as GMT. Ish.

GMT is only valid for 6 months of the year. Then, due to DST, it becomes BST.

UTC is just UTC.

Also, your DST may not be on the same day as GMT->BST.

Using the timezone America/Los_Angeles holds all the various shifts in
DST and offset that have been recorded, so you can use current local
time (shifted with DST just like you would read off your watch of PC)
with that timezone and PHP can work out what the timestamp is.

It sounds a little messy, but the TLA timezones aren't always sufficient.

Derick did a really good talk about this a couple of years ago for
php|Architect. I'm sure there's a video somewhere of it.

All makes perfect sense in the end.

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to