Jump to content

[SOLVED] getting date in different time zone


hchsk

Recommended Posts

how can i get the date() function to return a time in a different time zone, in this case EDT, America/New_York

 

date_default_timezone_set('EDT');
$nowpub = date("D, j M Y g:i:s");

 

DateTimeZone('America/New_York');
$nowpub = date("D, j M Y g:i:s");

 

both of these fail. any ideas/help/suggestions will be greatly appreciated.

i do not have access to .ini this must be accomplished within a script

What php version? What is the current code? strftime() does not take into account the time zone, only language settings, you must still set the time zone before using it. And DateTimeZone is a an class, you don't just call it like a function.

PHP Version 5.2.6

 

maybe i was confused about strftime use, i will try again, when i looked at the manual i though (wrongly i suppose) that you needed to identify the language settings, not the time zones, haha, and even that only if you wanted to display a textual representation of the month or day

ah, sorry, i missed your reply, but i'm still not quite getting it somehow, im now getting a value way off, hours plus 4 and date plus twenty, i dont understand that at all. i think the problem is my setlocale(), ive looked at the links you posted but still dont seem to understand what value i need for EDT, US east, or nyc

im using it to set the value of a $var, in format equivalent to date("D, j M Y g:i:s"); which will be used to post as the pubDate on an RSS item.

 

theres actually another problem there, but one that i can live with not solving, which is when i post a date in proper format EDT, rss changes the time zone to AM. i don't know why, but it would seem to be only in its display, it does not change the actual value, so i can live with it, because its only really crucial when i grab the value with XPATH externally for use in a dynamic script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.