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.

1 thought on “ datetime

  1. Pingback: Introducing « devioblog

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.