ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateDateHelper.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
14  public function formatDate(string $date, $dateFormat = null) : string
15  {
16  if (null === $dateFormat) {
17  $dateFormat = IL_CAL_DATETIME;
18  }
19 
20  $oldDatePresentationValue = ilDatePresentation::useRelativeDates();
22 
23  $date = ilDatePresentation::formatDate(new ilDate($date, $dateFormat));
24 
25  ilDatePresentation::setUseRelativeDates($oldDatePresentationValue);
26 
27  return $date;
28  }
29 
36  public function formatDateTime(string $dateTime, $dateFormat = null) : string
37  {
38  if (null === $dateFormat) {
39  $dateFormat = IL_CAL_DATETIME;
40  }
41 
42  $oldDatePresentationValue = ilDatePresentation::useRelativeDates();
44 
45  $date = ilDatePresentation::formatDate(new ilDateTime($dateTime, $dateFormat));
46 
47  ilDatePresentation::setUseRelativeDates($oldDatePresentationValue);
48 
49  return $date;
50  }
51 }
const IL_CAL_DATETIME
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static useRelativeDates()
check if relative dates are used
Class for single dates.
Date and time handling
formatDate(string $date, $dateFormat=null)
formatDateTime(string $dateTime, $dateFormat=null)