question about date format

Welcome Forums General PowerShell Q&A question about date format

Viewing 4 reply threads
  • Author
    Posts
    • #216609
      Participant
      Topics: 28
      Replies: 67
      Points: 375
      Rank: Contributor

      Hi

      I have a small question about date format
      I use Get-Date -Format “yyyy-MM-dd” which gives me 2020-04-08 however I would like to see 2020-apr-08
      how do I achieve this?
      the same for this one
      (get-date).AddDays(-1).ToString(“yyyy-MM-dd”)

      thanks for the pointers

       

      never mind sorted out in the mean time

      • This topic was modified 1 month, 2 weeks ago by acer460527.
    • #216618
      Participant
      Topics: 4
      Replies: 82
      Points: 251
      Helping Hand
      Rank: Contributor

      The format argument in your examples is called a format string specifier.  Here is a link to the documentation for custom date/times: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

       

    • #216627
      Participant
      Topics: 1
      Replies: 2
      Points: 3
      Rank: Member

      this may do what you need.  I did a “help get-date -full” and found the info.

      Get-Date -UFormat “%Y-%b-%d”

      2020-Apr-08

    • #216651
      Participant
      Topics: 4
      Replies: 2231
      Points: 5,414
      Helping Hand
      Rank: Community MVP

      Why so complicated? 😉

      Get-Date -Format 'yyyy-MMM-dd'

      and BTW: if you want to have the full name of the month … guess what …

      Get-Date -Format 'yyyy-MMMM-dd'

      😉

    • #216837
      Participant
      Topics: 28
      Replies: 67
      Points: 375
      Rank: Contributor

      thanks everyone for your input
      @olaf I figured that part out as well as mentioned on my original question I found the solution shortly after I posted my question

       

      Best regards

      Paul

Viewing 4 reply threads
  • You must be logged in to reply to this topic.