PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Calculation / DateTimeExcel / Current.php

Current.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php

61 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
4
5 use DateTime;
6 use DateTimeImmutable;
7 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
8
9 class Current
10 {
11 /**
12 * DATENOW.
13 *
14 * Returns the current date.
15 * The NOW function is useful when you need to display the current date and time on a worksheet or
16 * calculate a value based on the current date and time, and have that value updated each time you
17 * open the worksheet.
18 *
19 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
20 * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
21 *
22 * Excel Function:
23 * TODAY()
24 *
25 * @return DateTime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object,
26 * depending on the value of the ReturnDateType flag
27 */
28 public static function today()
29 {
30 $dti = new DateTimeImmutable();
31 $dateArray = Helpers::dateParse($dti->format('c'));
32
33 return Helpers::dateParseSucceeded($dateArray) ? Helpers::returnIn3FormatsArray($dateArray, true) : ExcelError::VALUE();
34 }
35
36 /**
37 * DATETIMENOW.
38 *
39 * Returns the current date and time.
40 * The NOW function is useful when you need to display the current date and time on a worksheet or
41 * calculate a value based on the current date and time, and have that value updated each time you
42 * open the worksheet.
43 *
44 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
45 * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
46 *
47 * Excel Function:
48 * NOW()
49 *
50 * @return DateTime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object,
51 * depending on the value of the ReturnDateType flag
52 */
53 public static function now()
54 {
55 $dti = new DateTimeImmutable();
56 $dateArray = Helpers::dateParse($dti->format('c'));
57
58 return Helpers::dateParseSucceeded($dateArray) ? Helpers::returnIn3FormatsArray($dateArray) : ExcelError::VALUE();
59 }
60 }
61