List of Topics
Main Page
How many times has this happened to you?--> You're doing something at the command prompt and you think 'garsh, wouldn't it be nice if I could get Windows XP to give me the date and time right from here, just by typing a command?... I know I know, I could hit the Windows key to bring up the Taskbar and get a look at the clock by the System Tray... But what if I set up the Taskbar not to show the clock, just to keep the clutter down?...  And damnit, the nearest time piece is in the kitchen and I'm too lazy to go there.... Whatever will I do???'  The solution is simple... type: time /t and press ENTER, or date /t and ENTER.  The /t switch lets you bypass the setting part and outputs the current time or date on screen.
<Note:  A reader in Germany wrote to say that the Date /t command wouldn't show the day of the week on his XP machine.  After looking around on the Web, I found that the day of the week is displayed only if you have selected US English in Control Panel's Regional and Language Settings, or if you chose US English during installation.  I opted for US English out of convenience and habit, and I assumed that the day of the week would be displayed for everyone.  Sometimes ignorance is not bliss. :)  My apologies to people who ran into the same trouble with the Date format.>

I stuffed both commands into a batch file that looks like this:

@echo off
echo.
date /t
echo.
time /t
echo.

If you decide to use this batch file or one like it, you'll be better off running it from the command line, rather than launching it as a shortcut on the Desktop or the Start Menu.

<For more on batch files, visit Gord's World of Batch Files and become a member of the free Batch World mailing list.
Still more info on batch files can be found here:
    - Using batch files (Microsoft)
    - Batch File Commands (Windows Support Center)
    - Information On Batch Files (Computer Hope)
>

I named the file above, "when.bat", and put it in a folder (also known as a directory) called c:\bat whose name I had listed in the path statement.  The path statement tells Windows where to look for commands.  You can find and change the path statement by doing the following:
    - right-click My computer / choose Properties
    - click the Advanced tab and click the Environment Variables box at the bottom of the panel
    - under System variables, choose Path from the list and click the Edit button to add a directory to the list
    - do this by placing a semicolon (;) at the end of the line and typing the name of the directory where you store batch files ... As an example, I keep batch files in a folder named "BAT" on the root of the C drive (c:\bat), so the line for me looks like this:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\dos;c:\bat

    - click OK or press ENTER to get out of the dialogs

The end of the story goes like this... when I type "when" (no quotes) at the command line, XP returns the date and time in the following format:

Sun 03/14/2004

11:31 PM

By the way, if you want to modify the format in which Time and Date are displayed in the command window and elsewhere in XP:
    - go to Start / Run... / type intl.cpl / press ENTER or click OK ... this opens the Regional and Language Options panel
    - choose Customize... under the Regional Options tab
    - the next dialog will show the tabs for Time and Date, along with others


For more on Regional and Language Options, see these:
    - Regional and Language Options overview (Microsoft)
    - Date, Time, Language, and Regional Options (The Elder Geek)

List of Topics
Main Page