From da7e6671007f36d46a585a3802a19da56f054bad Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 7 Nov 2015 08:09:49 +0000 Subject: [PATCH] added parseLDAPTimeStamp() --- lam/lib/account.inc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index dae50cdd..ee495cac 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -917,6 +917,17 @@ function compareDN(&$a, &$b) { * @return String formated time */ function formatLDAPTimestamp($time) { + $dateTime = parseLDAPTimestamp($time); + return $dateTime->format('d.m.Y H:i:s'); +} + +/** + * Parses an LDAP time stamp and returns a DateTime in current time zone. + * + * @param String $time LDAP time value + * @return DateTime time + */ +function parseLDAPTimestamp($time) { // Windows format: 20140118093807.0Z // OpenLDAP format: 20140118093807Z // cut off "Z" @@ -927,7 +938,7 @@ function formatLDAPTimestamp($time) { } $dateTime = DateTime::createFromFormat('YmdHis', $timeNumbers, new DateTimeZone('UTC')); $dateTime->setTimezone(getTimeZone()); - return $dateTime->format('d.m.Y H:i:s'); + return $dateTime; } /**