FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » local time, not server time
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
local time, not server time [message #32884] Mon, 31 July 2006 17:13 Go to next message
esm2002 is currently offline  esm2002   United States
Messages: 339
Registered: May 2002
Location: Atlanta Georgia
Karma: 0
Senior Member
Is there an easy way to change the time that shows when printing a report.

I have
<?php
date
("g:i:s a")
?>

but that shows the server time which is in another time zone from where I live.

I saw the setlocale function at php.net but that did not change anything. well, it changed other things but not the time.

help!


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Re: local time, not server time [message #32952 is a reply to message #32884] Sun, 06 August 2006 19:05 Go to previous messageGo to next message
kenjb is currently offline  kenjb   United States
Messages: 67
Registered: September 2004
Karma: 0
Member
What report?

<?php
$hourdiff = "0";
$timeadjust = ($hourdiff * 60 * 60);
$last_modified = filemtime("index.php");
echo"Last Modified: ";
$adjtime =date("l F j, Y g:ia", $last_modified + $timeadjust);
print ("$adjtime");
echo" EDT";
?>


The above takes the time a file was last changed and if needed, can modify the time by adding a number to "$hourdiff". Just take your local time as you have it listed and add the new vaiable to the $hourdiff in the &adjtime calculation.

That make sense?

lets see:

<?php
$hourdiff = "-1";
$timeadjust = ($hourdiff * 60 * 60);
$adjtime =date ("g:ia", + $timeadjust);
print ("$adjtime");
?>


With the above whatever the server time is, the display time now will be -1 hour.

That help?


kenjb

[Updated on: Sun, 06 August 2006 19:08]

Report message to a moderator

Re: local time, not server time [message #32954 is a reply to message #32952] Sun, 06 August 2006 21:15 Go to previous message
kenjb is currently offline  kenjb   United States
Messages: 67
Registered: September 2004
Karma: 0
Member
ooops. Try this one.

<?php
$date=date(U); // format date for calculation in seconds
//print ("$date");  //if you want to see the date format now
$hourdiff = "1"; //change the server time plus one hour
$timeadjust = ($hourdiff * 60 * 60); //this is how to calc it
$adjtime = date("g:ia", $date + $timeadjust); //format display
print ("$adjtime");  //print the adjusted time
?>

This one works!


kenjb
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Forced downgrade of PHP
Next Topic: php/sql design help
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 00:08:25 GMT 2024

Total time taken to generate the page: 0.02120 seconds