Solved

How do I return the time that's showing on my box using PHP?

Posted on 2015-01-08
3
77 Views
Last Modified: 2015-01-08
When I do this:

echo date("g:i a");

I get 7:06 PM. Looks great! But the time on my computer is 12:06 PM.

I'm running this script from my localhost, and since I'll have users all over the place, I didn't want to set my default time zone for this particular function. I just want to post the same time that's sitting on their computer on my site.

How?
0
Comment
Question by:brucegust
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40538559
Linux systems set the local hardware clock to GMT 0.  You Have to use the time zone to get local time at the server.  You have to use javascript to get the local time in the client's browser.  None of this is your choice.
http://php.net/manual/en/function.date-default-timezone-set.php
0
 

Author Comment

by:brucegust
ID: 40538827
Thanks, Dave!

Found a Javascript clock that works great!

Rock on!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40538841
You're welcome.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question