Forum Moderators: coopster & phranque

Message Too Old, No Replies

Changing Time zone

         

Old_Honky

4:48 pm on Mar 28, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



I am putting an SSI on some of my pages to give the date and time.

I don't know much about CGI scripts but I am trying to learn enough to get by. I don't want to use php because a) I don't know much about it either, and b) I have already used lots of SSI's to bring in shared content navigation etc.

I have found two choices

<!--#echo var="DATE_LOCAL" -->

gives me the local time at the host's server

<!--#echo var="DATE_GMT" -->

gives me GMT.

The problem is I am in UK and the host is in a different European time zone.

Is there a way of making the time display what is local to me rather than the server? GMT's no good because for half the year it will be wrong.

We have only UK customers so if they see the time is an hour ahead and given as CEST instead of BST they will become confused.

perl_diver

5:22 am on Mar 29, 2007 (gmt 0)

10+ Year Member



SSI is not CGI programming. You would probably be best using javascript for this which will display the local time of the client. There could be an SSI solution but I don't know much more than the basics of SSI. You could use an SSI tag to call a server side script and setup the script to output the date/time in any TZ or format you want.

<!--#include virtual="cgi-bin/date.cgi" -->

where date.cgi is a simple perl script:

#!/usr/bin/perl
$date = scalar localtime(time-3600);
print "Content-type: text/html\n\n";
print $date;
exit(0);

where -3600 is a one hour negative offset of the server time. You apply whatever value is appropriate.