I can use following to append a date to a text:
"Foo {0:G} Foo" -f (date) #returns "Foo 2009-12-07 15:34:16 Foo"
But I want the time in Unix format.
I can get it by date -UFormat %s
, but can I use the same syntax?
When I use -UFormat %s
I get 1260199855,65625, how do I remove the decimal?
To find the unix current timestamp use the %s option in the date command. The %s option calculates unix timestamp by finding the number of seconds between the current date and unix epoch.
Unix epoch timestamps are supported in the following formats: 10 digit epoch time format surrounded by brackets (or followed by a comma). The digits must be at the very start of the message. For example, [1234567890] or [1234567890, other] followed by the rest of the message.
Use of the TEXT Function to Convert Unix Timestamp to Date in Excel. We can also use the TEXT function to convert Unix timestamp values to Excel dates.
[int](Get-Date -UFormat %s -Millisecond 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With