support Windows timestamps

This commit is contained in:
Roland Gruber 2015-11-01 10:20:39 +00:00
parent 8e125eb168
commit 89421417fe
1 changed files with 7 additions and 0 deletions

View File

@ -917,7 +917,14 @@ function compareDN(&$a, &$b) {
* @return String formated time
*/
function formatLDAPTimestamp($time) {
// Windows format: 20140118093807.0Z
// OpenLDAP format: 20140118093807Z
// cut off "Z"
$timeNumbers = substr($time, 0, -1);
// for Windows cut off ".0"
if (strpos($timeNumbers, '.') == (strlen($timeNumbers) - 2)) {
$timeNumbers = substr($timeNumbers, 0, -2);
}
$dateTime = DateTime::createFromFormat('YmdHis', $timeNumbers, new DateTimeZone('UTC'));
$dateTime->setTimezone(getTimeZone());
return $dateTime->format('d.m.Y H:i:s');