datetime default output format

Welcome Forums General PowerShell Q&A datetime default output format

This topic contains 7 replies, has 5 voices, and was last updated by

 
Participant
8 months ago.

  • Author
    Posts
  • #95798

    Participant
    Points: 0
    Rank: Member

    Hi,
    if i type Get-Date i get the following output (german):

    Dienstag, 13. März 2018 12:34:47
    (Get-Date).GetType()
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     True     DateTime                                 System.ValueType

    It is a DateTime object.

    I would like to change the default output of Get-Date to 13.03.2018 12:34:47 but keep the Type as DateTime (so i cant you ToString()??)

    Can i do this without changing the regional settings in Windows?
    Can you suggest how the get to this?

    Thanks

  • #95799

    Participant
    Points: 13
    Rank: Member

    Could you not use

    Get-Date -Format "ddMMyyyy HH:MM:ss"

    • #95801

      Participant
      Points: 0
      Rank: Member

      It is changed to string object then.

  • #95804
    js

    Participant
    Points: 207
    Helping Hand
    Rank: Participant
    • #95808

      Participant
      Points: 0
      Rank: Member

      Thanks is there no other way than creating a psx1ml file?

      My goal is to have date in this format and to make it sortable in Powershell Universal Dashboard (Out-UDGridData)

    • #95831

      Participant
      Points: 22
      Rank: Member

      You can format the date on the client-side with UD, if that is helpful. I added some documentation to the Gitbook about it: https://adamdriscoll.gitbooks.io/powershell-universal-dashboard/content/grids.html

    • #95865

      Participant
      Points: 0
      Rank: Member

      Thanks Adam, this worked well.

  • #95813

    Keymaster
    Points: 1,624
    Helping HandTeam Member
    Rank: Community Hero

    It's determined by your operating system settings. So no, you can't modify it except by making a String.

The topic ‘datetime default output format’ is closed to new replies.