时间戳转换

在系统内部,活动目录使用的Ticks时间(单位是从1601年开始100纳秒)来表示时间日期。在过去这是很难转换成人类可读的时间日期的。这里有个容易的方法:

[DateTime]::FromFileTime(635312826377934727)

同样的,将日期时间转换成Ticks,使用这个方法:

(Get-Date).Ticks

 
$s = get-date "3/30/2016 13:54:03"
$stime = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime($s)

字符串转换为datetime
[datetime]::ParseExact("20171121","yyyyMMdd",$null)
posted on 2016-03-30 15:53  momingliu11  阅读(751)  评论(0编辑  收藏  举报