PHP - manually create date containing difference to greenwich
I've developed application which uses PayPal Adaptive Payments and for the Preapproval call I need to send startDate and endDate variable开发者_开发问答s which should be in the following format:
2004-02-12T15:19:21+00:00
Now - since application is international, there are different time zones so I need to send each preapproval based on the timezone of the specific person - any idea how can I create the date in the above format from a standard mysql date (Y-m-d H:i:s) ?
I have a table of difference to greenwich values (i.e. +01:00, + 02:00), of which values are associated with the user - so I can pass it as parameter to the method which would create the date and time.
I think it's also worth mentioning that I've set up default timezone in the config using:
date_default_timezone_set('UTC');
Any help would be much appreciated.
Maybe I misunderstood your question... But you can calculate each user's time by parsing those '+2:00' differences to hours and use it in such a way:
date('c', strtotime('+2 hours'));
If your server's time is UTC, this gives you current time for your '+2:00' user
For a custom date you do
date('c', strtotime('+2 hours', strtotime($customDate)))
;
精彩评论