The datetime command of the collection outputs the current date and time.

Using the -f (format) switch to select a .Net date format string (standard, custom), you can adjust the output format:

14.04.2011 16:11

D:\projects\cmdnet\net40>datetime -f D
Donnerstag, 14. April 2011

D:\projects\cmdnet\net40>datetime -f T

D:\projects\cmdnet\net40>datetime -f o

D:\projects\cmdnet\net40>datetime -f u
2011-04-14 16:15:15Z

Use the -utc switch to retrieve the UTC timestamp:

D:\projects\cmdnet\net40>datetime -f o -utc

The -ci switch selects a CultureInfo to display the date in a different language:

D:\projects\cmdnet\net40>datetime -ci fr -f D
jeudi 14 avril 2011

D:\projects\cmdnet\net40>datetime -ci fr-fr -f D
jeudi 14 avril 2011

(I noticed that the language-only culture info only works in .Net 4)

If you want to display the date string in a language that is not supported in the DOS code page, you need to first switch the code page using the chcp command:

Aktive Codepage: 850.

input code page: 850
input Windows code page: 1252
input encoding: Western European (DOS)
output code page: 850
output Windows code page: 1252
output encoding: Western European (DOS)
culture: de-AT
LCID: 3079
culture display name: German (Austria)

D:\projects\cmdnet\net40>chcp 1251
Aktive Codepage: 1251.

D:\projects\cmdnet\net40>datetime -ci ru -f D
14 апреля 2011 г.

D:\projects\cmdnet\net40>chcp 850
Aktive Codepage: 850.

The current version of is available for download here.

One Response to datetime

  1. […] is available for download here, and contains the commands listci, listenc, netenv, netver, datetime, df, enc, guid, tee, uniq, xslt. Possibly related posts: (automatically generated)Biggest 10 users […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: