Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/How to add hours to datetime in php?
Next
In Process
Lou Grenier
  • 12
Lou Grenier
Asked: May 21, 20222022-05-21T19:01:19+00:00 2022-05-21T19:01:19+00:00In: php

How to add hours to datetime in php?

  • 12

. Advertisement .

..3..

. Advertisement .

..4..

I am doing my first exercises in Php about how to add hours to datetime in php, your recommendations are highly appreciated in order for me to improve it. Thanks.

♦ Suggestions of ITtutoria Team
The addhours class lets you add hours to a date that has been stored in a date/time field. It’s simple and will save you the headache of manually calculating days, months, or years from your current datetime.

Here is our case study:

date('Y-m-d H:i',strtotime('+1 hour +20 minutes',strtotime($start)));
hours to datetime
  • 3 3 Answers
  • 24 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

3 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Agathe Moulin
    2022-05-21T19:01:22+00:00Added an answer on May 21, 2022 at 7:01 pm
    $new_time = date("Y-m-d H:i:s", strtotime('+5 hours'));
    • 21
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Juliette Mallet
    2022-05-21T19:01:26+00:00Added an answer on May 21, 2022 at 7:01 pm
    $date = new DateTime('2006-12-12 15:00');
    $date->modify('+1 hour');
    echo $date->format('Y-m-d'); // 2006-12-12 16:00
    • 18
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  3. Lina Pujol
    2022-05-21T19:01:25+00:00Added an answer on May 21, 2022 at 7:01 pm
    $minutes_to_add = 5;
    ​
    $time = new DateTime('2011-11-17 05:05');
    $time->add(new DateInterval('PT' . $minutes_to_add . 'M'));
    ​
    $stamp = $time->format('Y-m-d H:i');
    • 13
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.