Share

This topic contains 2 replies, has 2 voices, and was last updated by  Michael Pietroforte 2 months, 2 weeks ago.

  • Author
    Posts
  • #240984
     tmack 
    Participant
    • Topics: 1
    • Replies: 1
    Post count: 3
    Member Points: 85

    Hi Guys,

    I don’t see anything on the site discussing PowerShell and how to convert time values. A blog post would be awesome.

    What I am currently trying to do is automate updating a config file that has the epoch time based on the last time the file was modified/written to so I need to get the LastWriteTimeUTC and convert that to epoch time then update the file with that value.

    Surprisingly I didn’t find much on the internet for this specific scenario.

    Thanks in advance to whomever might write this up.

    0
  • #240987
     tmack 
    Participant
    • Topics: 1
    • Replies: 1
    Post count: 3
    Member Points: 85

    I figured it out:
    $ConfigFile = Get-Item .\ImAConfigFile

    Get-Date -Date “$ConfigFile.LastWriteTime” -UFormat %s

    1502800186.98396

    1+

    Users who have liked this topic:

    • avatar
    • #243714
       Michael Pietroforte 
      Keymaster
      • Topics: 138
      • Replies: 330
      Post count: 1019
      Member Points: 6,751

      Thanks for posting the answer. 🙂

      0

You must be logged in to reply to this topic.

CONTACT US

Please ask IT administration questions in the forum. Any other messages are welcome.

Sending
© 4sysops 2006 - 2017

Log in with your credentials

or    

Forgot your details?

Create Account