You are not logged in.

#1 12 Feb 2007 16:35

Splat
Member
Registered: 09 Feb 2007
Posts: 6

Date/Time Formatting

Hi,


Is it possible to grab the system (or universal) time and convert it to a YYYY-MM-DD-HH-MM-SS format? I have been looking through the SS64 site and have done several googles but haven't managed to find anything useful yet.


Thanks for you time,
Si++

Offline

#2 12 Feb 2007 19:47

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Date/Time Formatting

You should be able to modify this to get the format you want: just leave out the last part on the last line

http://ss64.com/vb/syntax-getdatetime.html

Alternatively, if you just want to assume the 20th century, any of the other scripts (under Syntax) can be modified like so:

SET YYYY=20%YY%

Offline

#3 04 Sep 2018 22:34

Carl Ingalls
New Member
Registered: 04 Sep 2018
Posts: 4

Re: Date/Time Formatting

The TIME command and the %time% variable are supposed to use the same format.  However, this is what I get on my Windows 7 machine:

C:\>time /t
05:23 PM  1723

C:\>echo %time%
17:23:09.48

I am able to edit the time format for the time command, but I don't know where the time format for the environment variable %time% is set.  Can anyone help with this?

Offline

#4 05 Sep 2018 09:26

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Date/Time Formatting

time /t and %time% are a built in command and variable respectively.  If it's even possible to customise them, I doubt it's a good idea.

That said, you can manipulate the output they produce into some other form which might be the solution you're looking for -- what exactly are you trying to achieve?


cmd | *sh | ruby | chef

Offline

Board footer

Powered by