ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateDateHelper.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
31  public function formatDate($date, ?int $dateFormat = null): string
32  {
33  if (null === $dateFormat) {
34  require_once 'Services/Calendar/classes/class.ilDateTime.php'; // Required because of global contant IL_CAL_DATE
35  $dateFormat = IL_CAL_DATETIME;
36  }
37 
38  $oldDatePresentationValue = ilDatePresentation::useRelativeDates();
40 
41  $date = ilDatePresentation::formatDate(new ilDate($date, $dateFormat));
42 
43  ilDatePresentation::setUseRelativeDates($oldDatePresentationValue);
44 
45  return $date;
46  }
47 
54  public function formatDateTime($dateTime, ?int $dateFormat = null): string
55  {
56  if (null === $dateFormat) {
57  require_once 'Services/Calendar/classes/class.ilDateTime.php'; // Required because of global contant IL_CAL_DATE
58  $dateFormat = IL_CAL_DATETIME;
59  }
60 
61  $oldDatePresentationValue = ilDatePresentation::useRelativeDates();
63 
64  $date = ilDatePresentation::formatDate(new ilDateTime($dateTime, $dateFormat));
65 
66  ilDatePresentation::setUseRelativeDates($oldDatePresentationValue);
67 
68  return $date;
69  }
70 }
formatDate($date, ?int $dateFormat=null)
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
formatDateTime($dateTime, ?int $dateFormat=null)
static setUseRelativeDates(bool $a_status)
set use relative dates