@@ -145,7 +145,7 @@ Obtains the current date-time from the system clock in the
145
145
specified time-zone. If no time-zone is specified, the ` UTC `
146
146
time-zone will be used.
147
147
148
- ** Throws :**
148
+ ** Exceptions :**
149
149
150
150
` TimeZoneException ` if the time-zone name cannot be found
151
151
@@ -191,7 +191,7 @@ their Unix epoch value (00:00:00 UTC on 1 January 1970).
191
191
192
192
` $timeZone ` the time-zone name or the offset from UTC/Greenwich
193
193
194
- ** Throws :**
194
+ ** Exceptions :**
195
195
196
196
` OutOfRangeException ` if the value of any unit is out of range
197
197
@@ -226,13 +226,13 @@ if something went wrong.
226
226
227
227
` $timeZone ` the time-zone name or the offset from UTC/Greenwich
228
228
229
- ** Returns :**
229
+ ** Return Values :**
230
230
231
- ` Ok<string> ` if no error was found
231
+ ` Ok<string> ` if no error is found
232
232
233
- ` Error<ParseException> ` if something went wrong
233
+ ` Error<ParseException> ` if the text cannot be parsed
234
234
235
- ** Throws :**
235
+ ** Exceptions :**
236
236
237
237
` InvalidArgumentException ` if an empty list of formats is passed
238
238
@@ -251,7 +251,7 @@ date-time formats (e.g. `'Fri, 17 Feb 2023 17:30:09 UTC'`).
251
251
The date-time is returned directly if no error is found,
252
252
otherwise an exception is thrown.
253
253
254
- ** Throws :**
254
+ ** Exceptions :**
255
255
256
256
` ParseException ` if the text cannot be parsed
257
257
@@ -268,7 +268,7 @@ date-time formats (e.g. `'Fri, 17 Feb 2023 17:30:09 GMT'`).
268
268
The date-time is returned directly if no error is found,
269
269
otherwise an exception is thrown.
270
270
271
- ** Throws :**
271
+ ** Exceptions :**
272
272
273
273
` ParseException ` if the text cannot be parsed
274
274
@@ -294,7 +294,7 @@ It is possible to parse texts with milliseconds (e.g.
294
294
The date-time is returned directly if no error is found,
295
295
otherwise an exception is thrown.
296
296
297
- ** Throws :**
297
+ ** Exceptions :**
298
298
299
299
` ParseException ` if the text cannot be parsed
300
300
@@ -311,7 +311,7 @@ format (e.g. `'Fri, 17 Feb 2023 17:30:09 +0000'`).
311
311
The date-time is returned directly if no error is found,
312
312
otherwise an exception is thrown.
313
313
314
- ** Throws :**
314
+ ** Exceptions :**
315
315
316
316
` ParseException ` if the text cannot be parsed
317
317
@@ -337,7 +337,7 @@ It is possible to parse texts with milliseconds (e.g.
337
337
The date-time is returned directly if no error is found,
338
338
otherwise an exception is thrown.
339
339
340
- ** Throws :**
340
+ ** Exceptions :**
341
341
342
342
` ParseException ` if the text cannot be parsed
343
343
@@ -363,7 +363,7 @@ It is possible to parse texts with milliseconds (e.g.
363
363
The date-time is returned directly if no error is found,
364
364
otherwise an exception is thrown.
365
365
366
- ** Throws :**
366
+ ** Exceptions :**
367
367
368
368
` ParseException ` if the text cannot be parsed
369
369
@@ -427,11 +427,30 @@ The text is not returned directly, but a [result][php-results-doc]
427
427
that will contain the text if no error was found, or an exception if
428
428
something went wrong.
429
429
430
- ** Returns :**
430
+ ** Return Values :**
431
431
432
- ` Ok<string> ` if no error was found
432
+ ` Ok<string> ` if no error is found
433
433
434
- ` Error<FormatException> ` if something went wrong
434
+ ` Error<FormatException> ` if the format is incorrect
435
+
436
+
437
+ ### formatted
438
+
439
+ ``` php
440
+ public function formatted(string $format = DateTime::ISO8601): string;
441
+ ```
442
+
443
+ Formats this date-time using the specified format.
444
+
445
+ If the format is not specified, the ISO 8601 date-time format
446
+ will be used (` Y-m-d\TH:i:sp ` ).
447
+
448
+ The text is returned directly if no error is found, otherwise
449
+ an exception is thrown.
450
+
451
+ ** Exceptions:**
452
+
453
+ ` FormatException ` if the format is incorrect
435
454
436
455
437
456
### toCookie
@@ -735,7 +754,7 @@ public function microsecondsSinceEpoch(): array;
735
754
Returns the number of seconds and microseconds after the Unix
736
755
epoch (00:00:00 UTC on 1 January 1970).
737
756
738
- ** Returns :**
757
+ ** Return Values :**
739
758
740
759
` array{0: int, 1: int} ` the number of seconds and microseconds
741
760
@@ -873,10 +892,12 @@ specify overflow and units other than years, months, days,
873
892
hours, minutes, seconds and microseconds, since only the order
874
893
of the seven first parameters is guaranteed.
875
894
876
- ** Throws :**
895
+ ** Exceptions :**
877
896
878
897
` InvalidArgumentException ` if a ` Period ` is combined with some time units
879
898
899
+ ` ArithmeticError ` if any value exceeds the PHP limits for an integer
900
+
880
901
881
902
### minus
882
903
@@ -921,10 +942,12 @@ specify overflow and units other than years, months, days,
921
942
hours, minutes, seconds and microseconds, since only the order
922
943
of the seven first parameters is guaranteed.
923
944
924
- ** Throws :**
945
+ ** Exceptions :**
925
946
926
947
` InvalidArgumentException ` if a ` Period ` is combined with some time units
927
948
949
+ ` ArithmeticError ` if any value exceeds the PHP limits for an integer
950
+
928
951
929
952
### with
930
953
@@ -962,7 +985,7 @@ day, hour, minute, second, microsecond and time-zone.
962
985
963
986
` $timeZone ` the time-zone name or the offset from UTC/Greenwich
964
987
965
- ** Throws :**
988
+ ** Exceptions :**
966
989
967
990
` OutOfRangeException ` if the value of any unit is out of range
968
991
@@ -987,13 +1010,15 @@ public function add(
987
1010
int $quarters = 0,
988
1011
int $weeks = 0,
989
1012
int $milliseconds = 0,
990
- ): Ok;
1013
+ ): Ok|Error ;
991
1014
```
992
1015
993
1016
Makes a copy of this date-time with the specified amount of
994
1017
years, months, days, hours, minutes, seconds and microseconds
995
- added. It works the same as the [ plus()] ( #plus ) method, but
996
- returns a [ result] [ php-results-doc ] instead of the new date-time.
1018
+ added.
1019
+
1020
+ It works the same as the [ plus()] ( #plus ) method, but returns a
1021
+ [ result] [ php-results-doc ] instead of the new date-time.
997
1022
998
1023
The result will contain the new date-time if no error was found,
999
1024
or an exception if something went wrong.
@@ -1002,11 +1027,13 @@ However, if a `Period` is combined with any time unit, the
1002
1027
exception will not be captured, allowing it to be thrown
1003
1028
normally.
1004
1029
1005
- ** Returns :**
1030
+ ** Return Values :**
1006
1031
1007
- ` Ok<static> ` if no error was found
1032
+ ` Ok<static> ` if no error is found
1008
1033
1009
- ** Throws:**
1034
+ ` Error<ArithmeticError> ` if any value exceeds the PHP limits for an integer
1035
+
1036
+ ** Exceptions:**
1010
1037
1011
1038
` InvalidArgumentException ` if a ` Period ` is combined with some time units
1012
1039
@@ -1029,13 +1056,15 @@ public function subtract(
1029
1056
int $quarters = 0,
1030
1057
int $weeks = 0,
1031
1058
int $milliseconds = 0,
1032
- ): Ok;
1059
+ ): Ok|Error ;
1033
1060
```
1034
1061
1035
1062
Makes a copy of this date-time with the specified amount of
1036
1063
years, months, days, hours, minutes, seconds and microseconds
1037
- subtracted. It works the same as the [ minus()] ( #minus ) method, but
1038
- returns a [ result] [ php-results-doc ] instead of the new date-time.
1064
+ subtracted.
1065
+
1066
+ It works the same as the [ minus()] ( #minus ) method, but returns
1067
+ a [ result] [ php-results-doc ] instead of the new date-time.
1039
1068
1040
1069
The result will contain the new date-time if no error was found,
1041
1070
or an exception if something went wrong.
@@ -1044,11 +1073,13 @@ However, if a `Period` is combined with any time unit, the
1044
1073
exception will not be captured, allowing it to be thrown
1045
1074
normally.
1046
1075
1047
- ** Returns :**
1076
+ ** Return Values :**
1048
1077
1049
- ` Ok<static> ` if no error was found
1078
+ ` Ok<static> ` if no error is found
1050
1079
1051
- ** Throws:**
1080
+ ` Error<ArithmeticError> ` if any value exceeds the PHP limits for an integer
1081
+
1082
+ ** Exceptions:**
1052
1083
1053
1084
` InvalidArgumentException ` if a ` Period ` is combined with some time units
1054
1085
@@ -1068,10 +1099,11 @@ public function copy(
1068
1099
): Ok|Error;
1069
1100
```
1070
1101
1071
- Makes a copy of this date with the specified year, month, day,
1072
- hour, minute, second, microsecond and time-zone. It works the
1073
- same as the [ with()] ( #with ) method, but returns a [ result] [ php-results-doc ]
1074
- instead of the new date-time.
1102
+ Makes a copy of this date-time with the specified year, month, day,
1103
+ hour, minute, second, microsecond and time-zone.
1104
+
1105
+ It works the same as the [ with()] ( #with ) method, but returns a
1106
+ [ result] [ php-results-doc ] instead of the new date-time.
1075
1107
1076
1108
The result will contain the new date-time if no error was found,
1077
1109
or an exception if something went wrong.
@@ -1094,11 +1126,13 @@ or an exception if something went wrong.
1094
1126
1095
1127
` $timeZone ` the time-zone name or the offset from UTC/Greenwich
1096
1128
1097
- ** Returns:**
1129
+ ** Return Values:**
1130
+
1131
+ ` Ok<static> ` if no error is found
1098
1132
1099
- ` Ok<static >` if no error was found
1133
+ ` Error<OutOfRangeException >` if the value of any unit is out of range
1100
1134
1101
- ` Error<OutOfRangeException| TimeZoneException> ` if something went wrong
1135
+ ` Error<TimeZoneException> ` if the time-zone name cannot be found
1102
1136
1103
1137
1104
1138
[ php-results-doc ] : https://hereldar.github.io/php-results/
0 commit comments