PHP date function - removing time

Posted on 2003-03-06
Medium Priority
Last Modified: 2006-11-17

I'm using the date function to return the date into a news page I'm making (nothing big, just some feeds I like that I'm still working on - http://chris.clook.net/news/syn.php ), and the time on the server is five hours ahead of my local time. Here's the code I've used for the time http://chris.clook.net/news/syn.php.txt - what can I use to take five hours off? I tried many things with the letter Z (from the PHP manual) subtracting 18000 seconds (five hours), but I haven't gotten anything to work. Does anybody know what I'm doing wrong?

Thanks, Chris
Question by:christo87
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

splishsplash earned 200 total points
ID: 8085482
Here's a couple ways to do it:
echo date("l, F d Y h:i a",strtotime ("-18000 seconds"));
echo date("l, F d Y h:i a",time()-18000);

Expert Comment

ID: 8086914
Here you are:

date("M-d-Y H:i:s", mktime(date("G")-5, date("i"), date("s"), date("m"), date("d"), date("Y")));

The mktime function do exactly what you need whenever you want to change time and date.


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 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