add 6 hours to the following date

Posted on 2008-06-22
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 r format ( RFC 2822 formatted date)

Is their anyway for me to add like 6 hours to this date?
Question by:casit
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
LVL 49

Expert Comment

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

Accepted Solution

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;
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

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!


Author Comment

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


Author Comment

ID: 21852110
LVL 48

Assisted Solution

hernst42 earned 500 total points
ID: 21852723

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

Author Comment

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

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

632 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