Blame view

vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php 2.15 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  <?php
  
  namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
  
  use DateTimeImmutable;
  use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  
  class Current
  {
      /**
       * DATENOW.
       *
       * Returns the current date.
       * The NOW function is useful when you need to display the current date and time on a worksheet or
       * calculate a value based on the current date and time, and have that value updated each time you
       * open the worksheet.
       *
       * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
       * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
       *
       * Excel Function:
       *        TODAY()
       *
       * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
       *                        depending on the value of the ReturnDateType flag
       */
      public static function today()
      {
          $dti = new DateTimeImmutable();
          $dateArray = date_parse($dti->format('c'));
  
          return is_array($dateArray) ? Helpers::returnIn3FormatsArray($dateArray, true) : Functions::VALUE();
      }
  
      /**
       * DATETIMENOW.
       *
       * Returns the current date and time.
       * The NOW function is useful when you need to display the current date and time on a worksheet or
       * calculate a value based on the current date and time, and have that value updated each time you
       * open the worksheet.
       *
       * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
       * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
       *
       * Excel Function:
       *        NOW()
       *
       * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
       *                        depending on the value of the ReturnDateType flag
       */
      public static function now()
      {
          $dti = new DateTimeImmutable();
          $dateArray = date_parse($dti->format('c'));
  
          return is_array($dateArray) ? Helpers::returnIn3FormatsArray($dateArray) : Functions::VALUE();
      }
  }