PowerShell – Convert Unix or Epoch time to readable format

Powershell has Get-Date cmdlet that has a parameter to format Unix (Epoch) time to readable format. If you want to convert normal time to Unix (Epoch) time, click here

CommandGet-Date EpochTime -uFormat %x

Example: Get-Date 130941281616085699 -UFormat %x

Please note, the argumens to -uFormat parameter are case sensitive. You can use any option individually or in combination, depending on your requirement.

Below is the screenshot with different arguments and the list of options available.







Options available for uFormat values:

D    Date in mm/dd/yy format (06/14/06)
x    Date in standard format for locale (09/12/07 for English-US)

C   Century (20 for 2006)
Y   Year in 4-digit format (2006)
y   Year in 2-digit format (06)
G   Same as ‘Y’
g   Same as ‘y’

b   Month name – abbreviated (Jan)
B   Month name – full (January)
h   Same as ‘b’
m   Month number (06)

W  Week of the year (00-52)
V   Week of the year (01-53)
U   Same as ‘W’

a   Day of the week – abbreviated name (Mon)
A   Day of the week – full name (Monday)
u   Day of the week – number (Monday = 1)
d   Day of the month – 2 digits (05)
e   Day of the month – digit preceded by a space ( 5)
j    Day of the year – (1-366)
w   Same as ‘u’

p   AM or PM
r   Time in 12-hour format (09:15:36 AM)
R   Time in 24-hour format – no seconds (17:45)
T   Time in 24 hour format (17:45:52)
X   Same as ‘T’
Z   Time zone offset from Universal Time Coordinate (UTC) (-07)

H   Hour in 24-hour format (17)
I    Hour in 12 hour format (05)
k   Same as ‘H’
l    Same as ‘I’ (Upper-case I = Lower-case L)

Minutes & Seconds:
M   Minutes (35)
S   Seconds (05)
s   Seconds elapsed since January 1, 1970 00:00:00 (1150451174.95705)

1 Comment

  1. Pingback: PowerShell – Convert Date and Time to Unix or Epoch format | WinPlat.Net

Comments are closed.