ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
formatDate(string $date, $dateFormat=null)
formatDateTime(string $dateTime, $dateFormat=null)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
Class for single dates.