The datetime command of the cmd.net 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:
D:\projects\cmdnet\net40>datetime 14.04.2011 16:11 D:\projects\cmdnet\net40>datetime -f D Donnerstag, 14. April 2011 D:\projects\cmdnet\net40>datetime -f T 16:15:24 D:\projects\cmdnet\net40>datetime -f o 2011-04-14T16:15:02.9943652+02:00 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 2011-04-14T14:16:13.3573897Z
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:
D:\projects\cmdnet\net40>chcp Aktive Codepage: 850. D:\projects\cmdnet\net40>netenv 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 cmd.net is available for download here.
Pingback: Introducing cmd.net « devioblog