Re: using perl to print yesterday's date, but with formatting options ?
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Mon, 31 Oct 2005 18:25:54 +0100
Gunnar Hjalmarsson wrote:
Tom Van Overbeke wrote:
I need a way to use yesterday's date in a variable. The tricks with 'date' don't work on my system, but perl does.
so i've got: perl -le 'print scalar localtime time - 86400' which outputs: Sun Oct 30 17:56:52 2005
But the format I need is: 30.10.05
Any ideas on how to add this to the above piece of code ?
Capture the date string in a variable and use the tr/// operator.
Sorry, didn't read the question carefully enough.
Either you can get the date components by evaluating localtime() in list context
perldoc -f localtime
and create the date string you want 'by hand', or you can use one of the many date modules.
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl .
- Prev by Date: parametrical substitution in perl
- Next by Date: Re: using perl to print yesterday's date, but with formatting options ?
- Previous by thread: parametrical substitution in perl
- Next by thread: Re: using perl to print yesterday's date, but with formatting options ?
- Index(es):
Relevant Pages
|
|