Good Morning everyone, Welcome back to Learn Tech Tips Blog, continue the blog Javascript working with date and times from client side. Today we will check PHP working with date and time too from server side.
If you know this technical, so you don't be worry about it any more on any project from Server side, client side, because you had got knowledge for working with them
Ok Let's begin for check how to working with date and time with PHP. I will share you example, so you shall easy understand it
date('Y-m-d h:i:s', strtotime('-30 minutes')): // get current time minus 30 minutes
date('Y-m-d'); // get current date
$day_temp = date('Y-m-d', strtotime(date('Y-m-d') . "+1 years")); // current year: 24/02/2022 => result: 24/02/2023: get next year
$day_temp = date('Y-m-d', strtotime(date('Y-m-d') . "+1 months")); // get current date add more 1 months
$day_temp = date('Y-m-d', strtotime(date('Y-m-d') . "+15 days")); // get current date add more 15 days
$extended_day = (strtotime(date('Y-m-d')) - strtotime($od_date)) / (60 * 60 * 24); // get number of day between with current date with od_date
$next_year = date('Y', strtotime($loan_date . "+" . "1 months")); // get loan_date variable of Year after plus 1 months
$next_month = date('m', strtotime($loan_date)) ; // get loan_date variable of month
$repayment_dates = date('Y-m-d', strtotime($new_year . '/' . $new_month . '/' . $new_day)); // convert 3 variable new_year, new_month, new_day to date time
$settings['duration'] = strtotime($settings['duration']) - time(); // get duration between setting['duration] params with current time
pr (date('j/n/y', strtotime('+4 months')));
// add more 4 months from current date
// current date is: 24/02/2022 // => result: 24/6/22
pr (date('Y-m-d', strtotime('+4 months +2 weeks ')));
// add more 4 months 2 weeks from current date
pr (date('Y-m-d', strtotime('+4 months +2 weeks +3 days')));
// add more +4 months +2 weeks +3 days from current date
// current date is: 24/02/2022 // => result: 2022-07-11
If you have any feedback or questions about PHP working with date and time using strtotime, leave your comment on below topic, we can discuss about it!
#php
#phplearntechtips
#phpzidane
Zidane