Unix and Linux Discussions Tagged with date |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
9 |
18,320 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,885 |
Shell Programming and Scripting |
|
|
|
2 |
1,996 |
Shell Programming and Scripting |
|
|
|
4 |
3,238 |
Fedora |
|
|
|
1 |
6,105 |
Shell Programming and Scripting |
|
|
|
3 |
1,786 |
Shell Programming and Scripting |
|
|
|
1 |
4,066 |
Shell Programming and Scripting |
|
|
|
2 |
10,394 |
Shell Programming and Scripting |
|
|
|
2 |
2,466 |
Shell Programming and Scripting |
|
|
|
1 |
2,378 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
1,413 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
79,615 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,700 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,175 |
Shell Programming and Scripting |
|
|
|
2 |
2,722 |
Shell Programming and Scripting |
|
|
|
6 |
6,949 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
7,430 |
Shell Programming and Scripting |
|
|
|
2 |
2,170 |
Shell Programming and Scripting |
|
|
|
2 |
2,180 |
Red Hat |
|
|
|
6 |
1,748 |
Shell Programming and Scripting |
|
|
|
0 |
4,692 |
UNIX and Linux Applications |
|
|
|
1 |
2,037 |
Shell Programming and Scripting |
|
|
|
4 |
7,546 |
Shell Programming and Scripting |
|
|
|
6 |
2,414 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,505 |
Shell Programming and Scripting |
|
|
|
3 |
2,167 |
Shell Programming and Scripting |
|
|
|
9 |
5,192 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
2,200 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
4,240 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
12,758 |
Shell Programming and Scripting |
|
|
|
3 |
2,365 |
Shell Programming and Scripting |
|
|
|
10 |
4,613 |
Shell Programming and Scripting |
|
|
|
4 |
3,873 |
Shell Programming and Scripting |
|
|
|
7 |
27,965 |
Shell Programming and Scripting |
|
|
|
4 |
15,655 |
Shell Programming and Scripting |
|
|
|
0 |
3,113 |
Shell Programming and Scripting |
|
|
|
1 |
9,671 |
Shell Programming and Scripting |
|
|
|
1 |
23,014 |
Shell Programming and Scripting |
|
|
|
4 |
19,822 |
Shell Programming and Scripting |
|
|
|
3 |
5,008 |
UNIX for Dummies Questions & Answers |
DATETIME.SETDATE(3) 1 DATETIME.SETDATE(3)
DateTime::setDate - Sets the date
Object oriented style
SYNOPSIS
public DateTime DateTime::setDate (int $year, int $month, int $day)
DESCRIPTION
Procedural style
DateTime date_date_set (DateTime $object, int $year, int $month, int $day)
Resets the current date of the DateTime object to a different date.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $year
- Year of the date.
o $month
- Month of the date.
o $day
- Day of the date.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | Changed the return value on success from NULL to |
| | DateTime. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
DateTime.setDate(3) example
Object oriented style
<?php
$date = new DateTime();
$date->setDate(2001, 2, 3);
echo $date->format('Y-m-d');
?>
Procedural style
<?php
$date = date_create();
date_date_set($date, 2001, 2, 3);
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2001-02-03
Example #2
Values exceeding ranges are added to their parent values
<?php
$date = new DateTime();
$date->setDate(2001, 2, 28);
echo $date->format('Y-m-d') . "
";
$date->setDate(2001, 2, 29);
echo $date->format('Y-m-d') . "
";
$date->setDate(2001, 14, 3);
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-02-28
2001-03-01
2002-02-03
SEE ALSO
DateTime.setISODate(3), DateTime.setTime(3).
PHP Documentation Group DATETIME.SETDATE(3)