Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Local Time as opposed to server time

Status
Not open for further replies.

tobytyke2002

Technical User
Mar 15, 2005
7
GB
Hi i know absolutely nothing about cgi so i leave all that to the smart people. i just use their scripts.

My problem is this:

i am using a formmail scripts that emails me the message and puts the time on the email when the message was left. It is using my hosts server time which is about 5 hours behind my time.

Having looked at the script i think that this is where it gets the time.

sub get_date {

# Define arrays for the day of the week and month of the year. #
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');

# Get the current time and format the hour, minutes and seconds. Add #
# 1900 to the year to get the full 4 digit year. #
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;

# Format the date. #
$date = "$days[$wday], $months[$mon] $mday, $year at $time";


How do i change this to make it pick up UK time.

Any help appreciated
 
Just add or subtract the appropriate number of hours to or from the $hour variable.

If you need to the time to be 3 hours later, something like...
Code:
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$hour += 3;
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top