Unix and Linux Discussions Tagged with date |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
3 |
5,960 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,886 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,500 |
UNIX for Beginners Questions & Answers |
|
|
|
13 |
17,095 |
Shell Programming and Scripting |
|
|
|
2 |
6,915 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
3,050 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
4,684 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
4,365 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
8,695 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,976 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
2,459 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
2,344 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
2,213 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
1,829 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,663 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
3,098 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,298 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
3,412 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,446 |
UNIX for Beginners Questions & Answers |
|
|
|
20 |
5,207 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
5,230 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
3,507 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
21,753 |
Shell Programming and Scripting |
|
|
|
0 |
11,936 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
14,700 |
Linux |
|
|
|
2 |
2,288 |
Shell Programming and Scripting |
|
|
|
3 |
7,123 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,377 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,291 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,905 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
1,591 |
UNIX for Beginners Questions & Answers |
|
|
|
13 |
4,562 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
1,924 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
4,111 |
Ubuntu |
|
|
|
1 |
9,286 |
Answers to Frequently Asked Questions |
|
|
|
2 |
2,877 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
9,739 |
Shell Programming and Scripting |
|
|
|
3 |
14,513 |
Shell Programming and Scripting |
|
|
|
20 |
12,735 |
HP-UX |
|
|
|
7 |
14,338 |
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)