Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use UFormat to get unix time

Tags:

powershell

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?

like image 946
magol Avatar asked Dec 07 '09 14:12

magol


People also ask

How do you find time in Unix?

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.

What format is Unix timestamp?

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.

Can Excel convert Unix timestamp?

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.


1 Answers

[int](Get-Date -UFormat %s -Millisecond 0)
like image 119
Anton Avatar answered Oct 02 '22 13:10

Anton