Unix and Linux Discussions Tagged with date |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
3 |
9,806 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
6,984 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
2,373 |
UNIX for Beginners Questions & Answers |
|
|
|
13 |
20,134 |
Shell Programming and Scripting |
|
|
|
2 |
9,995 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,910 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
7,132 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
5,698 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
10,883 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
3,961 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
3,561 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,388 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,470 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,471 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,454 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
4,557 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,896 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,809 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
3,260 |
UNIX for Beginners Questions & Answers |
|
|
|
20 |
8,390 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
6,467 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
4,726 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
25,512 |
Shell Programming and Scripting |
|
|
|
0 |
13,026 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
17,462 |
Linux |
|
|
|
2 |
3,451 |
Shell Programming and Scripting |
|
|
|
3 |
8,056 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
3,719 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
3,719 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
3,103 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,489 |
UNIX for Beginners Questions & Answers |
|
|
|
13 |
7,053 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
3,246 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
6,398 |
Ubuntu |
|
|
|
1 |
12,318 |
Answers to Frequently Asked Questions |
|
|
|
2 |
5,295 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
12,344 |
Shell Programming and Scripting |
|
|
|
3 |
17,296 |
Shell Programming and Scripting |
|
|
|
20 |
17,895 |
HP-UX |
|
|
|
7 |
18,162 |
Shell Programming and Scripting |
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)