setDate

We can assign new date to any date object by using setDate function. Using this we can change the date object.
setDate(Year, month, day)
Here are some examples to set the date.
date_default_timezone_set('America/Chicago');
$today = new DateTime;
echo $today->format('Y-m-d ');
echo "<br>";
$today->setDate(13,11,20);
echo $today->format('Y-m-d');
The output is here
2020-02-19 
0013-11-20
IN above code we can change the setDate function parameters and check the output. We can change to higher values for year and month , the function will adjust it to the next values and display the correct dates. Here are the changes ( only )
$today->setDate(13,14,31);
The output is here
2020-02-19 
0014-03-03

Procedural style

$date = date_create();
date_date_set($date, 2019, 8, 13);
echo date_format($date, 'Y-m-d');
Output is here
2019-08-13


plus2net.com






hgggfhhfhf ghf

26-08-2014

how to display this (Fri May 14 12:03:24 IST
2010)
slon

23-04-2015

Rather limited class. There is no easy way to get year, month, date etc. Stuid date difference returns a hole class istead of value in items I provide ('d', 'm', 'q' etc) as MSSQL & other conventional DateDiff functions do.

Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer