NOW.php 699 B

123456789101112131415161718192021222324252627
  1. <?php
  2. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  3. require __DIR__ . '/../../Header.php';
  4. $category = 'Date/Time';
  5. $functionName = 'NOW';
  6. $description = 'Returns the serial number of the current date and time';
  7. $helper->titles($category, $functionName, $description);
  8. // Create new PhpSpreadsheet object
  9. $spreadsheet = new Spreadsheet();
  10. $worksheet = $spreadsheet->getActiveSheet();
  11. $worksheet->setCellValue('A1', '=NOW()');
  12. $worksheet->getStyle('A1')
  13. ->getNumberFormat()
  14. ->setFormatCode('yyyy-mm-dd hh:mm:ss');
  15. // Test the formulae
  16. $helper->log(sprintf(
  17. 'Today is %f (%s)',
  18. $worksheet->getCell('A1')->getCalculatedValue(),
  19. $worksheet->getCell('A1')->getFormattedValue()
  20. ));