in reply to Re: How to get the current Date and Time using Perl on windows?
in thread How to get the current Date and Time using Perl on windows?

As everyone has pointed out, there are much better, more perlish ways to do it, but here my $0.02 in the interest of TIMTOWTDI in case you're in a DOS batch file mindset.

First, date /? reports:

Displays or sets the date. DATE [/T | date] Type DATE without parameters to display the current date setting and a prompt for a new one. Press ENTER to keep the same date. If Command Extensions are enabled the DATE command supports the /T switch which tells the command to just output the current date, without prompting for a new date.

If Command Extensions are missing, you can pipe the ENTER like this:
echo.|date

which is a little harder to parse, but also doesn't require setting the date.

C:\chas_sandbox>perl -le "print `date /T`" Wed 01/02/2008 C:\chas_sandbox>perl -le "print `echo.\|date`" The current date is: Wed 01/02/2008 Enter the new date: (mm-dd-yy) C:\chas_sandbox>


I humbly seek wisdom.

Replies are listed 'Best First'.
Re^3: How to get the current Date and Time using Perl on windows?
by McDarren (Abbot) on Jan 03, 2008 at 01:15 UTC
    The problem with this is that the OP was after a date and time stamp, and the DOS date command only gives the date. You could I suppose use a combination of both the date and time commands, but that would be just silly™

    Obviously, the OP has a script that was written for a *nix environment and he is trying to port it to winders.

      touchée. What version of ACME::ESP are you runing? Mine seems out of date (no pun intended; well, ok, maybe intended a little ;) ).


      I humbly seek wisdom.