Python LDAP中的时间戳转换为Linux下时间
(Get-ADUser zhangsan -Properties badpasswordtime).badpasswordtime返回值为:131172610187388712
131172610187388712为长整型时间戳(18位),精确到了纳秒级别。该时间戳是从1601-01-01 8:00:00开始计算
1472791840.74是Linux下的时间戳(默认都是13位),精确到了秒级别。该时间是从1970-01-01 8:00:00开始计算
在Python下,无法直接通过datetime.datetime.fromtimestamp('131172610187388712')将131172610187388712转换为可读时间,转换方法如下:
t=''
t_n = long(t)*100/1000000000 #将其从纳秒转换为秒
#从1601-01-01 8:00:00到1970-01-01 8:00:00共经过了11644473600秒,所以需要先将其减掉,然后再进行转换
print datetime.datetime.fromtimestamp(t_n-11644473600) #返回:2016-09-02 11:19:46 print datetime.datetime.fromtimestamp(t_n) #返回2385-09-02 11:19:46
Windows下直接查看时间戳:w32tm /ntte 131172599865898976,返回值:151820 03:19:46.5898976 - 2016/9/2 11:19:46

时间戳计算:
11644473600秒*1000000000 = 11644473600000000000纳秒
转换为活动目录时间戳
11644473600000000000纳秒/100纳秒=116444736000000000
Python LDAP中的时间戳转换为Linux下时间的更多相关文章
- LINUX 下时间转换为秒数
linux下时间是从1970.1.1开始算的秒数 //转来自网址 http://blog.csdn.net/wind19/article/details/6579495 $ dateTue Feb 3 ...
- Linux下时间格式转换及获取方法
Linux下使用clock_gettime给程序计时 #include <stdio.h> #include <unistd.h> #include <stdlib.h& ...
- 在Firefox中发现一个在Linux下查看chm文档的插件
在Firefox浏览器插件中搜索插件chmfox插件,安装后就可以在linux下通过Firefox浏览器阅读chm文档了.
- linux下时间有关的函数和结构体
1.时间类型.Linux下常用的时间类型有6个:time_t,struct timeb, struct timeval,struct timespec,clock_t, struct tm. (1) ...
- python中pygame模块的Linux下安装过程
一.使用pip安装Python包 大多数较新的Python版本都自带pip,因此首先可检查系统是否已经安装了pip.在Python3中,pip有时被称为pip3. 1.在Linux和OS X系统中检查 ...
- 在Tomcat中配置域名:linux下的配置
域名的配置 端口要改成80 找到/usr/tomcat/apache-tomcat-8.5.30/conf的目录,找到server.xml文件,到 <Host name="localh ...
- Python之schedule用法,类似linux下的crontab
# -*- coding: utf-8 -*- # author:baoshan import schedule import time def job(): print("I'm work ...
- python列表中的值转换为字符串,及列表里的所有值拼接成一个字符串 的方法
后记: ls3='%'.join(ls2) 会把%加入拼接成的字符里面,同理,加入其它字符也一样,''空就是什么都不加,如上图 最后输出 1%我%22
- linux下时间操作1
本文是对我之前写的文章:C++时间操作 的更深入补充.之前那个文章就是一个快速入门的东西,后面力图把一些更深入的细节补充完整. 时间分类的基本介绍 在介绍一些时间相关的操作函数之前,先来介绍一下lin ...
随机推荐
- STF(SmartPhone Test Farm)Mac版本环境搭建
它的github页面为: https://github.com/openstf/stf 1.Linux一些基本包的安装: 在控制台分别运行 sudo apt-get update sudo apt-g ...
- VB6.0 调用存储过程
最近有在做一个需求,需要在VB6.0中调用存储过程,整理了一下,供大家参考, 范例: Function callStoredProcedure(sEmployeeID As String, Optio ...
- vnc 登录后只有终端 没有桌面 黑屏
1, start vnc server: vncserver :1 issue: connect it with pc and only display one terminal. 2, stop v ...
- OpenWRT连接OPENVPN的教程
这是相当基本没有任何web界面,只是几个命令如何运行OpenWRT的 OpenVPN的例子. OpenWRT的设置更复杂,所以这个教程仅供爱好者和经验的用户使用参考. 本教程假定您有OpenWRT的安 ...
- 再见Unity3d的死循环
前两天看见http://www.manew.com/thread-89909-1-1.html这篇译文之前几个小时刚好解决了一个莫名的死循环问题,然后忍不住要把另外一种方法告诉蛮友们.这个方法不需要知 ...
- 使用SqlBulkCopy, 插入整个DataTable中的所有数据到指定数据库中
string sql=""; dbhelper.ExecuteNonQuery(sql); DataTable dt = dbhelper.GetDataTable(sql); i ...
- iOS9的一些问题
1.App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. ...
- utime函数
utime函数:对一个文件的访问和修改时间 #include <utime.h> int utime( const char *pathname, const struct utimbuf ...
- javascript基础知识-对象
javascript创建对象有三种方法: 1)对象直接量 例:var empty = {}; var point = {x:1,y:4}; var book = { "main title& ...
- 《Automatic Face Classification of Cushing’s Syndrome in Women – A Novel Screening Approach》学习笔记
<针对女性库欣综合征患者的自动面部分类-一种新颖的筛查方法> Abstract 目的:库兴氏综合征对身体造成相当大的伤害如果不及时治疗,还经常是诊断的时间太长.在这项研究中,我们旨在测试面 ...