Solved

add 6 hours to the following date

Posted on 2008-06-22
8
805 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
[X]
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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

738 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