简体   繁体   中英

how to show current date and 200 days+current date in php

I have a project where I can show current date and time. After that I can show current date + 200 days after a date in PHP. I'm new in PHP programing

You can try something like this with DateTime()

<?php
$dt = new DateTime();
$currentDate = $dt->format("Y-m-d H:i:s");
$dt->add(new DateInterval("P200D")); 
$futureDate = $dt->format("Y-m-d H:i:s");
echo $currentDate;
echo PHP_EOL;
echo $futureDate;
?>

Program Output

2018-04-27 17:11:57
2018-11-13 17:11:57

DEMO: https://eval.in/996235

Code in php $data['plusday'] = $date = date('Ym-d') +$product_info['plusday'];

Twig {{ plusday }}

I am just geting output yers '2031' I what output to be current date + days. The amount of days is from database. The output I what is 07-09-2022 + 7 days.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM