Forum Moderators: coopster

Message Too Old, No Replies

Display the users unique date and time

not using javascript detect the users location and display there date/time

         

amdorsey

4:45 am on Mar 8, 2004 (gmt 0)

10+ Year Member



I know you can use a simple javascript to display the date and time, but I want to use PHP to eliminate client-side processing.

I want to display "Good Afternoon (or evening or morning, depending on what time, anyway...)

Good Morning! Today is March 7, 2004 at 11:43pm.

Is there any way using PHP to detect the location of the users time zone using ip addresses or something and displaying there accurate date and time.

Any suggestions, pros?

coopster

1:11 pm on Mar 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Time zone:
IP-to-Country.com
h**p://ip-to-country.webhosting.info/node/view/6

Date and time:
help required on - redirect on time - script [webmasterworld.com]

amdorsey

7:49 pm on Mar 8, 2004 (gmt 0)

10+ Year Member



Still no help. How about using the usings system clock to display the date and time, I suppose thats the next best thing.

Please a little help.

coopster

9:05 pm on Mar 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are your visitors logging in? I often show the user the server time, then ask them for an UTC offset (for example, -6). Set a cookie and you can give them the correct time for their time zone every time they visit your page(s) with the appropriate message, good morning, good afternoon, good evening...

bon jour.

jomaxx

4:30 pm on Mar 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would recommend Javascript except that the user's time and even date can often be wildly wrong. Chip clocks do not keep good time. (Reminder to make sure YOUR server has the correct time.)

I don't know if PHP can detect the time zone, but you could try a combination PHP/Javascript solution. Use PHP to set the standard time, and Javascript to convert it to local time before printing. If you do a Google search for something like Javascript Detect Time Zone, you should be able to find a few examples.

One problem I can foresee is page cacheing on the user's system and via provy servers. The time will only be correct when the PHP executes, so you might want to ensure the page always expires immediately.

Timotheos

5:27 pm on Mar 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this...
h**p://martin.f2o.org/php/localtime