Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2015-01-08
3
Medium Priority
?
81 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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

Expert Comment

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

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

971 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