Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
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 count occurrences of each item in an array.
Suggested Courses

564 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