Unix and Linux Discussions Tagged with date calculation |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
2 |
13,410 |
Homework & Coursework Questions |
|
|
|
5 |
3,037 |
Shell Programming and Scripting |
|
|
|
6 |
8,359 |
Shell Programming and Scripting |
|
|
|
5 |
20,919 |
Shell Programming and Scripting |
|
|
|
11 |
11,355 |
Shell Programming and Scripting |
|
|
|
1 |
947 |
Shell Programming and Scripting |
|
|
|
7 |
7,946 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
10,974 |
Shell Programming and Scripting |
|
|
|
6 |
34,615 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
6,139 |
Shell Programming and Scripting |
|
|
|
8 |
1,956 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
6,191 |
Shell Programming and Scripting |
|
|
|
4 |
1,499 |
Shell Programming and Scripting |
|
|
|
0 |
4,865 |
UNIX and Linux Applications |
|
|
|
2 |
7,540 |
Shell Programming and Scripting |
|
|
|
3 |
3,787 |
Shell Programming and Scripting |
|
|
|
2 |
3,356 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
69,128 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
2,052 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
5,241 |
Shell Programming and Scripting |
|
|
|
2 |
1,829 |
Shell Programming and Scripting |
|
|
|
4 |
7,472 |
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)