Clock

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Batch Artist
Posts: 22
Joined: 18 Oct 2013 05:28

Clock

#1 Post by Batch Artist » 20 Oct 2013 04:17

Hello guys, just a little point out here since I constantly get asked how to make a clock or a mechanism that shows you the time and/or date. The following codes are examples:

Code: Select all

@ECHO off
ECHO The time is %time%
ECHO The date is %date%


Code: Select all

@ECHO off
ECHO %time%     %date%


As you can see, Time and date variables are already existent, so there is no need to create variables or make huge lines of code to display time and date. Using the preset variables uses less time, and is very VERY simple to use!

Hope this helps!

.Batch Artist.

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: Clock

#2 Post by Adrianvdh » 25 Oct 2013 05:32

How about one the ticks?

Code: Select all

@echo off
:loop
cls
echo %time%
goto loop

Batch Artist
Posts: 22
Joined: 18 Oct 2013 05:28

Re: Clock

#3 Post by Batch Artist » 25 Oct 2013 05:36

Adrianvdh wrote:How about one the ticks?

Code: Select all

@echo off
:loop
cls
echo %time%
goto loop


Very true, and you can also add colouring into it aswell. E.G...

Code: Select all

@echo off
:Loop
CLS
ECHO %time%
color A
color B
color C
color D
color E
color F
color 9
GOTO Loop

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: Clock

#4 Post by Adrianvdh » 25 Oct 2013 06:07

I know dude, she! Everyone know that :)

Post Reply