Unix and Linux Discussions Tagged with date |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
3 |
11,437 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
7,724 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
2,990 |
UNIX for Beginners Questions & Answers |
|
|
|
13 |
20,392 |
Shell Programming and Scripting |
|
|
|
2 |
10,951 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
5,509 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
7,890 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
6,581 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
11,792 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,537 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
4,159 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,997 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
4,013 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,962 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
5,008 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
5,324 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
2,457 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
5,271 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
3,979 |
UNIX for Beginners Questions & Answers |
|
|
|
20 |
10,142 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
6,886 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
5,076 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
25,882 |
Shell Programming and Scripting |
|
|
|
0 |
13,575 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
18,091 |
Linux |
|
|
|
2 |
3,534 |
Shell Programming and Scripting |
|
|
|
3 |
8,511 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,083 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
4,289 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
3,532 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,894 |
UNIX for Beginners Questions & Answers |
|
|
|
13 |
7,844 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
3,694 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
7,838 |
Ubuntu |
|
|
|
1 |
14,669 |
Answers to Frequently Asked Questions |
|
|
|
2 |
6,037 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
12,676 |
Shell Programming and Scripting |
|
|
|
3 |
17,584 |
Shell Programming and Scripting |
|
|
|
20 |
20,913 |
HP-UX |
|
|
|
7 |
18,493 |
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)