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

x
?
Solved

PHP date function - removing time

Posted on 2003-03-06
2
Medium Priority
?
194 Views
Last Modified: 2006-11-17
Hi,

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
0
Comment
Question by:christo87
2 Comments
 
LVL 1

Accepted Solution

by:
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);
?>
0
 

Expert Comment

by:alfarod
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.

0

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