SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Date

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
2014-08-28 
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
2014-08-28 
0014-03-03

Be the first to post comment on this article :


Google+
Click for more tutorial on Date & Time functions and Applications


More On Date Object
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer