Twitch Posted October 11, 2008 Share Posted October 11, 2008 Hey guys I'm hoping someone can help me with making this script get the user's local computer time instead of the server time. I know php can't do it and I know javascript can, but I'm not sure how to do it with this script. I had another script I was working on that never quite worked, but this one does what I need it to do, but with the server time instead of the local time. Thanks in advance, Twitch Quote Link to comment https://forums.phpfreaks.com/topic/128002-local-machine-time-instead-of-server-time/ Share on other sites More sharing options...
wildteen88 Posted October 11, 2008 Share Posted October 11, 2008 PHP can retrieve the users local time by their timezone. Quote Link to comment https://forums.phpfreaks.com/topic/128002-local-machine-time-instead-of-server-time/#findComment-662813 Share on other sites More sharing options...
Twitch Posted October 11, 2008 Author Share Posted October 11, 2008 Whoops I forgot to post the code. <?php $b = time(); $hour = date("g",$b); $m = date("A", $b); $d = date("D", $b); echo $hour; echo $m; echo $d; if ($m == "AM") { if ($hour == 12) { echo "Good Evening!"; } elseif ($hour < 4) { echo "Good Evening!"; } elseif ($hour > 3) { echo "Good Morning!"; } } elseif ($m == "PM") { if ($hour == 12) { echo "Good Afternoon!"; } elseif ($hour < 7) { echo "Good Afternoon!"; } elseif ($hour > 6) { echo "Good Evening!"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/128002-local-machine-time-instead-of-server-time/#findComment-662816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.