creationtime to real date and time

Welcome Forums General PowerShell Q&A creationtime to real date and time

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

12 months ago.

  • Author
  • #94147

    Points: 1
    Rank: Member

    I can not figure out how to convert the creationtime to normal time. Here is the output i get in excel file which is 2018-02-18T23:51:55. I would like to convert it before i sent it to csv file. Here is the current code i have . I even tried the comment out code and did not work

    This is pulling multiple data and putting them in csv file.

        $startDate = (Get-Date).AddDays(-7).ToString('MM/dd/yyyy') 
        $endDate = (Get-Date).ToString('MM/dd/yyyy')
        $results = Search-UnifiedAuditLog -StartDate $startDate -EndDate $endDate  -UserIds $upn
    $ConvertedOutput = $results | Select-Object -ExpandProperty AuditData | ConvertFrom-Json
    $ConvertedOutput | Select-Object CreationTime,UserId,Operation,ResultStatus,ClientIP #| Export-Csv $OutputFile -NoTypeInformation -Append
     $ConvertedOutput | Export-Csv $OutputFile -NoTypeInformation
     #@{Name='CreationTime';Expression={Get-Date $_.CreationTime -Format 'MM\dd\yyyy'},
  • #94150

    Points: 706
    Helping Hand
    Rank: Major Contributor

    Why not just use .Net to convert it.

    Just use .Net to covert it
    Sunday, February 18, 2018 11:51:55 PM
    [datetime]'2018-02-18T23:51:55' -f 'ddMMMyyyy'
    02/18/2018 23:51:55
    • #94153

      Points: 1
      Rank: Member

      I will try that. i am almost there by using your information. Is there anyway not to have it military time ? It would be easier for my managers. I tried just date time but did not need the whole date .

      This would be a good format just with normal time

      [datetime]'2018-02-18T23:51:55' -f 'ddMMMyyyy'
      02/18/2018 23:51:55

      be this instead

      02/18/2018 11:51 PM

      Thank you so far for your help

The topic ‘creationtime to real date and time’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort