Click to See Complete Forum and Search --> : Timezones and PHP


EyesWideOpen
11-09-2000, 01:45 PM
I am trying to change the timezone that gets displayed on the posted articles of my site. I believe the following code is what formats the time. It is formatted in GMT and I want it to be in Eastern Standard Time(EST). My question is: How do you convert the value returned by time() from GMT to EST in PHP?


function formatTimestamp($time) { #$time holds the value returned by time()
include ("config.php");
global $datetime;
setlocale ("LC_TIME", "$locale");

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);

$datetime =

strftime("".translate("datestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));

$datetime = ucfirst($datetime);
return($datetime);
}



------------------
A PHP-Nuke powered site (http://www.cams.f2s.com)

Sweede
11-09-2000, 02:08 PM
less than one minute on php.net/manual/
http://www.php.net/manual/function.date.php

Convert Times between Timezones

// First set the Timezone
// (see the zoneinfo directory-tree on your System for a list
// it is in /usr/share/zoneinfo on my System)

putenv("TZ=Europe/Rome");

// Calculate the Timstamp relative to the Timezone

$timestamp=mktime($hour,$minutes,$seconds,$month,$ day,$year);

// Show the time

echo "Date ".date("d/m/Y H:i:s",$timestamp)." in ".getenv ("TZ")."\n";

// Now Change the Timezone

putenv("TZ=Australia/Adelaide");


// Show the time
echo "Date ".date("d/m/Y H:i:s",$timestamp)." in ".getenv ("TZ")."\n";

Sweede
11-09-2000, 02:11 PM
what is this from?
phpnuke ?

EyesWideOpen
11-09-2000, 03:22 PM
Originally posted by Sweede:
what is this from?
phpnuke ?

Yeah. It is.

less than one minute on php.net/manual/

I was at the manual several times but never read the user comments on the date() function, only time().

Thanks.

------------------
A PHP-Nuke powered site (http://www.cams.f2s.com)

Sweede
11-09-2000, 08:50 PM
i copied that section of code, then realized there was more to it than i thought.

downloaded php nuke and isntalled it on http://www.underthemain.net/nuke/

this phpnuke is pretty cool, so while im hackin away at the code, i'll let you know what i find.

mine right now is in military time, it says central, but its on mountain time, but the server is in florida so i got some hackin to do http://www.linuxnewbie.org/ubb/smile.gif

EyesWideOpen
11-09-2000, 11:29 PM
Originally posted by Sweede:
i copied that section of code, then realized there was more to it than i thought.

downloaded php nuke and isntalled it on http://www.underthemain.net/nuke/

this phpnuke is pretty cool, so while im hackin away at the code, i'll let you know what i find.

mine right now is in military time, it says central, but its on mountain time, but the server is in florida so i got some hackin to do http://www.linuxnewbie.org/ubb/smile.gif

Cool. I'll let you know what I come up with as well...

------------------
A PHP-Nuke powered site (http://www.cams.f2s.com)

Sweede
11-12-2000, 02:10 PM
hey, you done anyting new?

i modified it a little.

1. phorum is in there, you gotta be registered to post. if your not registered, it asks for authentication.
http://www.underthemain.net/forum.php

i also put a forum up there for people to trade pics or post images. i modified it to only allow image/* formats. renmaing a text file to jpg doesnt do it. next im going to modify it so it puts the uploaded file into their own directory.

2. im also signed up to everyone.net to give unlimited web-based email. when you register on my site, you automaticly get a @underthemain.net email address assigned to you.

3. a few other things that i forgot, heh.