polywogsys (polywogsys) wrote,
polywogsys
polywogsys

  • Mood:

Converting lastLogonTimestamp to Javascript Date Object

I am writing this down, because this is the last time I deal with this problem over and over again, having to have to reinvent the wheel in javascript.



var last_login = "132022299384906985";
var high   = last_login.substr(0,9);
var low    = last_login.substr(9,2);
var epoch  = (((parseInt(high) - 116444736) * 100) + parseInt(low) + 10800);
var millis = epoch * 1000;
//
// Not needed since source is UTC
//
// var localMillis = millis - (60000 * new Date().getTimezoneOffset());
//
lastLogon.getFullYear() 
  + ("00" + (lastLogon.getMonth()+1)).slice(-2) 
  + ("00" + lastLogon.getDate()).slice(-2) 
  + ("00" + (lastLogon.getHours())).slice(-2) 
  + ("00"+ lastLogon.getMinutes()).slice(-2) 
  + "Z";
Tags: lastlogon, ldap, windows
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments