Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Getting the date using PHP


  • Please log in to reply
6 replies to this topic

#1 Shadow Slash

Shadow Slash

  • Members
  • 25 posts
  • OFFLINE
  •  
  • Local time:09:25 PM

Posted 21 June 2010 - 01:36 AM

Hi,

How do I get the date using the website's server's time instead of the viewing computer's time. I need this because there tends to be some computers with incorrectly configured times or have CMOS batteries that have already died out and thus the internal clock keeps going back to the default time.

It needs to be done with PHP...

Thank you for those who'd help and belated happy father's day!

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:25 AM

Posted 21 June 2010 - 07:05 AM

When you use PHP, it is getting the time of the server since that is where PHP runs. Using Javascript, it would get it on the client side, since that is where it runs.

#3 Shadow Slash

Shadow Slash
  • Topic Starter

  • Members
  • 25 posts
  • OFFLINE
  •  
  • Local time:09:25 PM

Posted 21 June 2010 - 08:55 AM

When you use PHP, it is getting the time of the server since that is where PHP runs. Using Javascript, it would get it on the client side, since that is where it runs.

Lol wow! Didn't think that was how it worked! I always tried it on my local server and never tried it on a remote! Thanks for the quick info!

#4 Ryan M.

Ryan M.

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:08:25 AM

Posted 16 September 2010 - 03:35 AM

Hi there!

Can anyone can show me a code (using PHP or Javascript) that can display RUNNING date and time of client PC? For example, how can I view the current time and date of 10.0.0.1 (client IP add) :thumbsup: .

Thanks in advance

#5 Shadow Slash

Shadow Slash
  • Topic Starter

  • Members
  • 25 posts
  • OFFLINE
  •  
  • Local time:09:25 PM

Posted 16 September 2010 - 03:49 AM

Hi there!

Can anyone can show me a code (using PHP or Javascript) that can display RUNNING date and time of client PC? For example, how can I view the current time and date of 10.0.0.1 (client IP add) :thumbsup: .

Thanks in advance

Umm I don't think that's possible not unless you can make a them open a webpage containing a javascript that communicates with a PHP page on your end to send you the client's time. I'm not sure if that is the best approach though.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:25 AM

Posted 16 September 2010 - 09:23 AM

You can't use PHP to get anything on the client side because PHP runs on the server side. If you want the time, you have to use JavaScript, and have the JavaScript return the time to the server.

There are thousands of tutorials online that will show you how to use JavaScript to get date and time. There are also thousands of tutorials online that will show you how to use things like AJAX to communicate with the server. Using AJAX, you can send the date and time back to the server.

Maybe you could start by writing some JavaScript to get the date and time?

#7 Shadow Slash

Shadow Slash
  • Topic Starter

  • Members
  • 25 posts
  • OFFLINE
  •  
  • Local time:09:25 PM

Posted 16 September 2010 - 10:26 AM

There are also thousands of tutorials online that will show you how to use things like AJAX to communicate with the server. Using AJAX, you can send the date and time back to the server.

Ahh! AJAX was the term I've been wanting him to look up, I just couldn't remember the term. Thanks! :thumbsup:

Edited by Shadow Slash, 16 September 2010 - 10:26 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users