JSHINER Posted February 17, 2008 Share Posted February 17, 2008 I know using date() I can get the current date, time, etc of the server. Is there a way to get the same info of the users machine instead of the server? Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted February 17, 2008 Share Posted February 17, 2008 90% sure you are going to need a client side script i.e javascript to do that. Quote Link to comment Share on other sites More sharing options...
JSHINER Posted February 17, 2008 Author Share Posted February 17, 2008 I figured that - was hoping it wasn't the case I still like my 10% chance though ... anyone want to prove that 90% wrong? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 17, 2008 Share Posted February 17, 2008 Until (if ever) browsers start passing the client's date/time in the http request headers, you will need to code this yourself. This simplest way would be to use the following method and replace the width/height information with the client's date and time -http://www.php.net/manual/en/faq.html.php#faq.html.javascript-variable Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted February 17, 2008 Share Posted February 17, 2008 I figured that - was hoping it wasn't the case I still like my 10% chance though ... anyone want to prove that 90% wrong? I put 99% up at first lol.. but incase I was to be proven wrong I had to cover my back Quote Link to comment Share on other sites More sharing options...
JSHINER Posted February 17, 2008 Author Share Posted February 17, 2008 <script type="text/javascript"> <!-- var Days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var today = new Date(); var Hours = today.getHours(); Hours2 = Hours; Hours = leadingZero(Hours); var ampm = "am"; if (Hours2 > 11) ampm = "pm"; if (Hours2 > 12) Hours2 -= 12; if (Hours2 == 0) Hours2 = 12; Hours2 = leadingZero(Hours2); var Minutes = leadingZero(today.getMinutes()); function takeYear(theDate) { x = theDate.getYear(); var y = x % 100; y += (y < 38) ? 2000 : 1900; return y; } function leadingZero(nr) { if (nr < 10) nr = "0" + nr; return nr; } document.write (+ Hours2 + ':' + Minutes + ' ' + ampm); // --> </script> Is there ANY way to do this: if(document.write (+ Hours2 + ':' + Minutes + ' ' + ampm)=="10:00 am") { echo 'Morning'; } Not exactly like that I know, but that's basically what I want to do. Any ideas? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 17, 2008 Share Posted February 17, 2008 That is Javascript. Do you want that in PHP? If so, it will use the time on the server. Ken Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 17, 2008 Share Posted February 17, 2008 Since you asked "Is there a way to get the same info of the users machine" in the php (a server side scripting language) forum, I assumed that you wanted to get that information to a .php script on the server, which using the information in my post above can accomplish. What are you actually trying to accomplish? Quote Link to comment 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.