Skip to Content

How to convert AD accountexpires in Local timezone format

Oct 18, 2016 at 01:07 AM


avatar image

Hello Everyone,

In my current project IDM 7.2 SP10, we are reading accountexpires attribute from AD and then converting it to a readable format using uInt8ToDate function.

This function is converting the date in readable GMT format while client want it in local time. While searching SCN, I got below post which says that "True" switch is not working in uInt8ToDate function and even I observed the same.

Can anyone guide how can I convert the date in local timezone. I tried to use getTimezoneOffset() but it thrown error. Any help with the JavaScript formula will be appreciated.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Dominik Trui Oct 21, 2016 at 12:32 PM

Hello C Kumar,

I use this script to retrieve the accountExpires from AD and set it to the local validto attribute for AD:

var MSTimestamp = Par;
var MSTimestampNormalized = (MSTimestamp - 116444736000000000 - 864000000000) / 10000;
var date = new Date(MSTimestampNormalized);

var MonthValue = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
var dayOfMonth = '' + date.getDate();
if (dayOfMonth.length == 1) { dayOfMonth = "0" + dayOfMonth; }
return date.getFullYear() + "-" + MonthValue[date.getMonth()] + "-" + dayOfMonth;

Never thought of the time gap between GMT and CET though. I always take a day of (864000000000) due to the difference from accountExpires and validto.

I guess I would have to add or subtract another milliseconds value to match up the different time zones we have (plants all around the world) if sdomeone actually would complain about a user being locked too early just because of the day hasn't passed yet. I guess the local Domain Controllers in every country handle the date correctly.

If ever needed I would use a time zone difference in hours and store it on each company. Then I'd use this one in the script to add / subtract the amount of hours before calculating the new Date thingy.

Best regards


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Dominik,

Can you please let me know how to convert the current date to LDAP/filetime, so that enddate can be passed to the AccountExpires attribute in AD