Creating UNIX Time in Windows Script
I recently found myself needing to convert a date/time in a Windows vbs script to UNIX time and struggled to find an example of how to do this. Correct me if I’m wrong, but there doesn’t seem to be any built-in function to change 20070109161723+720 to 1168359443.
After fine-tuning a few Google queries I found using the DateDiff function the easiest way and came up with,
Function WMIDateToUNIX(strDate)
ConvertedDate = CDate(Mid(strDate, 7, 2) & "/" & _
Mid(strDate, 5, 2) & "/" & Left(strDate, 4) _
& " " & Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & Mid(strDate,13, 2))
WMIDateToUNIX = DateDiff(“s”, “01/01/1970 00:00:00″,ConvertedDate)
End Function
Not the prettiest code I’ll admit, but if someone else can use it that’s all well and good.
Leave a comment
Blog Categories
Recent Stuff
Twitter Updates
- RT @stevebiddle 'Why have a sign on your cafe saying "holiday surcharge applies"?' Or "we forgot holidays in our poorly planned business"
- Ahh that's right, this is the Harry Potter where the vampire gets killed at the end
- There's a problem being the social media guinea pig. Your friends aren't there when you sign up.
- @toxaq I thought he'd be taller. And be protected from people like you
- RT @timbray: âPiracy, copyright, profit, and kiss my ass.â http://t.co/Ky2Bi8n7 I think this one worth passing on.


