Asked 2 years ago
9 Jun 2021
Views 3474
debugger

debugger posted

how to add 10 days to date in php ?

how to add 10 or 20 or 30 or any days to date in php ?
sqltreat

sqltreat
answered Oct 8 '21 00:00

By using time() function in PHP
time() return current timestamp and by adding 10 day's second to it lead to time of after 10 day time
add 10 days to the current date.

date('Y-m-d',time()+3600*24*10);


add 20 days to the current date.

date('Y-m-d',time()+3600*24*20);


add 30 days to the current date.

date('Y-m-d',time()+3600*24*30);


By using strtotime() function in php
strtotime() function convert string to time .

add 10 days to the current date.

date('Y-m-d',strtotime("+10 days"));


add 20 days to the current date.

date('Y-m-d',strtotime("+20 days"));


add 30 days to the current date.

date('Y-m-d',strtotime("+30 days"));



add 10 days to any date.

date('Y-m-d',strtotime("2021-10-19 +10 days"));


add 20 days on any date.

date('Y-m-d',strtotime("2021-10-19 +20 days"));


add 30 days to any date.

date('Y-m-d',strtotime("2021-10-19 +30 days"));


web-api

web-api
answered Sep 7 '22 00:00

strtotime() is the function which can covert given string to time. it work like AI almost. where if you write "+10 days" , it will add 10 days to current time and return time after the 10 days.
strtotime("+10 days") -- return 10 days after time from current time.
Post Answer