Solved

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

Posted on 2015-01-08
3
74 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now