Posted inProgramming / Mysql / Mysqli / php

PHP Add Days Hours Minutes and Seconds to Datetime

PHP Add Days Hours Minutes and Seconds to Datetime

In this Post We Will Explain About is PHP Add Days Hours Minutes and Seconds to Datetime With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Add a duration or interval to a dateExample

In this post we will show you Best way to implement How to adds and substracts some days, months, years, hours, minutes, hear for Adds an amount of days, months, years, hours, minuteswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

How to add Days, Hours, Minutes, and Seconds to Datetime in PHP

Add days to datetime using PHP.
Add date functions to hours to datetime using PHP.
Add date functions to minutes to datetime using PHP.
Add date functions to seconds to datetime using PHP.


How to adds and substracts some days, months, years, hours, minutes

echo "
"; $firstStartDateTime = date("Y-m-d H:i:s"); //display the starting time using PHP echo 'Starting Time: '.$firstStartDateTime; //add 2 hour to time using PHP $FinalDateTime = date('Y-m-d H:i:s',strtotime('+2 hour',strtotime($firstStartDateTime))); //display the FinalDateTime time using PHP echo 'FinalDateTime Time (added 2 hour): '.$FinalDateTime; //add 2 hour and 20 minutes to time using PHP $FinalDateTime = date('Y-m-d H:i:s',strtotime('+2 hour +20 minutes',strtotime($firstStartDateTime))); //display the FinalDateTime time using PHP echo 'FinalDateTime Time (added 2 hour & 20 minutes): '.$FinalDateTime; //add 2 hour, 20 minutes and 30 seconds to time using PHP $FinalDateTime = date('Y-m-d H:i:s',strtotime('+2 hour +20 minutes +30 seconds',strtotime($firstStartDateTime))); //display the FinalDateTime time using PHP echo 'FinalDateTime Time (added 2 hour, 20 minutes & 30 seconds): '.$FinalDateTime; //add 2 day, 2 hour, 20 minutes and 30 seconds to time using PHP $FinalDateTime = date('Y-m-d H:i:s',strtotime('+2 day +2 hour +20 minutes +30 seconds',strtotime($firstStartDateTime))); //display the FinalDateTime time using PHP echo 'FinalDateTime Time (added 2 day, 2 hour, 20 minutes & 30 seconds): '.$FinalDateTime; echo "
";

Example

I hope you have Got What is How to add Days, Hours, Minutes, and Seconds to Datetime in PHP And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype