Jump to content

PS get-date is nice for logs/db


iamtheky
 Share

Recommended Posts

I am going through the command list on my win10 box and found get-date, dont know why i never used it prior.

#include <array.au3>

$sCommand = "powershell Get-Date"

$iPID = run($sCommand , "" , @SW_HIDE , $stdout_child)

$sOutput = ""

     While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then ExitLoop
    WEnd

ProcessClose($iPID)
msgbox(0, '' , $sOutput)

$aOut = stringsplit(stringreplace($sOutput , "," , ""), " " , 2)

_ArrayTranspose($aOut)
_ArrayDisplay($aOut)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I like it because with one command you also get day of the week, and if you prefer names to numbers, you dont have to convert month.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

54 minutes ago, iamtheky said:

with one command you also get day of the week, and if you prefer names to numbers

#include <Date.au3>
Exit ConsoleWrite(@CRLF & @CRLF & f_get_date() & @CRLF & @CRLF)
Func f_get_date()
    Local $sOut = ""
    $sOut &= _DateDayOfWeek(@WDAY)
    $sOut &= ", "
    $sOut &= _DateToMonth(@MON, $DMW_SHORTNAME)
    $sOut &= " "
    $sOut &= @MDAY
    $sOut &= ", "
    $sOut &= @YEAR
    $sOut &= " "
    $sOut &= _Time()
    Return $sOut
EndFunc   ;==>f_get_date

Func _Time() ; https://www.autoitscript.com/wiki/Snippets_(_Time_%26_Date_)#Time_3
    Local $hour = @HOUR, $AMPM = "AM"
    If $hour > 11 Then $AMPM = "PM"
    If $hour = 0 Then $hour = 12
    If $hour > 12 Then $hour -= 12
    Return StringRight("0" & $hour, 2) & ":" & @MIN & ":" & @SEC & " " & $AMPM
EndFunc   ;==>_Time

but I did not know the powershell command. Thanks for posting. 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...