Solved

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

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

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 82

Expert Comment

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

746 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