Q:

UNIX time in Powershell giving GMT

First off, I'm not a coder by profession, just a lowly network engineer :) But I'm a big believer in automation and try to write scripts to handle tasks they're suited for
I'm attempting to get the current UNIX timestamp for 10 minutes ago in PowerShell, for use in a database-check script.  I'm using this to get the current Unix-time:
$unixtime=[int][double]::Parse((Get-Date -UFormat %s))-600

But when I run it through a UNIX-time to local time converter (http://www.onlineconversion.com/unix_time.htm), I'm getting the current time in GMT (for example, if I run it right now I get "1340620608", which the converter says is 10:36 AM  GMT, when the actual time is 10:36 AM CDT).  This obviously causes issues when comparing to Unix timestamps in the database, as they are in local time.  While I could write (or find) a function that would calculate the current GMT offset and apply it to my timestamp, I was wondering if there is a better way to go about this.

A:

Try:
$unixtime=[int][double]::Parse($(Get-Date -date (Get-Date).ToUniversalTime()-uformat %s))

The above gets the current GMT time first then converts it to the correct format.

