in reply to Re^2: Converting POSIX format date/times to epoch seconds
in thread Converting POSIX format date/times to epoch seconds
I needed to convert the date from the WMIC command output so I added a block to the code (using a copy anyway for other reasons). it is small enough to customize and here is a small customization (which can probably be improved). I wanted to have a "better" way of determining up time - converting the boot time then taking the delta seemed to be a simple solution. FYI - Win32::GetTickCount was returning 13 days (in ms) on my machine which has been up for 150something days. using this change and time() function to get a delta produced a correct result.
# WMIC (Windows command line) Date output format from `wmic os get + lastbootuptime` (($yr, $mon, $day, $hr, $min, $sec) = /^ (\d{4}) # year (\d\d) # numerical month (\d\d) # day (\d\d) # Hour (\d\d) # Min (\d\d) # Sec /x) ||
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Converting POSIX format date/times to epoch seconds
by Anonymous Monk on Oct 21, 2014 at 15:31 UTC |