I need to print time in a batch file but command prompt tells me that the syntax is incorrect. Here is the code i have so far:
@echo %time% ping -n 1 -w 1 127.0.0.1 1>nul @echo %time% pause cls
I don't know why it isn't working, Please help Me.
You can use $T for time and $D for date, as well as several other expansions. See also: https://ss64.com/nt/prompt.html. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/prompt.
cmd - Script to get current time. GMT. cmd - Current time in GMT (World Time). Equivalent PowerShell: Get-Date - Get current date and time.
batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
This works with Windows 10, 8.x, 7, and possibly further back:
@echo Started: %date% %time% . . . @echo Completed: %date% %time%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With