Solved

add 6 hours to the following date

Posted on 2008-06-22
8
804 Views
Last Modified: 2008-11-12
I have the following date.
Sun, 22 Jun 2008 00:00:00 -0400
And I get this from converting a yyyy-mm-dd date to
http://us3.php.net/date r format ( RFC 2822 formatted date)

Is their anyway for me to add like 6 hours to this date?
0
Comment
Question by:casit
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 21843955
$newData = strtotime('+6 hours', $originalDate);
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21843962
$hour = time() + 6*3600;
or if you already have the value in a variable just
$newHour = $hour + 6*3600;
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21844047
just try,

print date("d/m/Y H:i:s",strtotime("+6 hours"));

Open in new window

0
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!

 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21844048
0
 

Author Comment

by:casit
ID: 21850582
Here is what I'm getting
Warning: strtotime() expects parameter 2 to be long, string given
with this code snippet
$date1 = $row['date'];
$newdate = date("r",strtotime($date1));
$newdate1 = strtotime('+6 hours',$newdate);

Open in new window

0
 

Author Comment

by:casit
ID: 21852110
anyone?
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 500 total points
ID: 21852723
Just

echo date("r",strtotime($date1)+6*3600);
0
 

Author Comment

by:casit
ID: 22945748
I actually figured the problem out.  It was using wrong timezone.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reverse engineer .sql from php files 11 49
Test if unique ID is in log file 5 31
Link failure 16 60
Difference between PHPClasse.php and SimplXLS.php 5 14
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

685 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