• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1162
  • Last Modified:

Display localhost time

Hi Experts,

What's the command to echo the following?
The synced time of Localhost is mm/dd/yyyy hr:min

rgds,
 
timesync.txt
0
kenny_klbn
Asked:
kenny_klbn
  • 2
2 Solutions
 
beanrodCommented:
@echo off
date /t
time /t
0
 
beanrodCommented:
or...

@echo off
echo The synced time of Localhost is %date% %time%
0
 
Farhan KaziSystems EngineerCommented:
Try this:
@ECHO OFF
SET MM=%DATE:~4,2%
SET DD=%DATE:~7,2%
SET YYYY=%DATE:~10,4%

FOR /F "Tokens=1-2 Delims=:" %%a IN ('ECHO %TIME%') DO (
	SET Hrs=%%a
	SET Min=%%b)

IF %Hrs% LSS 10 SET Hrs=0%Hrs%
SET LogFile=%MM%_%DD%_%YYYY%_%Hrs%_%Min%.txt

NET USE T: /delete >"%LogFile%"
NET USE T: \\RemoteServer\Share /USER:user Password >>"%LogFile%"
NET Time \\RemoteServer /set /yes >>"%LogFile%"

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now