Get the Client's Time in PHP
Find your user's local time with PHP pages. Step 1. Any current time will do. To get time and date on php, First you use the “unix timestamp” --- time(); --- to get the number of milliseconds or seconds since 1970 and it’s in Utah somewhere (UTC). Then to get those milliseconds into a date formate with years, months day of month, day of week, hour minute, you use: localtime(time(), TRUE); And this gets you the day and hour in Utah somewhere (UTC). Step 2. Personalized time for a single page. But to get the day and hour in your preferred time zone, there are two options because the client doesn’t automatically tell the HTTP server where or when the client exists. Either use Javascript to get the local time from the client. Or get the actual timezone from the client, transfer that via a new request to the server and resend the properly timed page. Step 2.A Prepare for ancient browser with no javascript. If the ...