Solved

add 6 hours to the following date

Posted on 2008-06-22
8
801 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
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21844048
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now