May 2007
Beginner
628 pages
15h 46m
English
You need to get yesterday or tomorrow’s date, and you have Perl but not GNU date on your system.
Use this Perl one-liner, adjusting the number of seconds added to
or subtracted from time:
# Yesterday at this same time (note subtraction)
$ perl -e "use POSIX qw(strftime); print strftime('%Y-%m-%d', localtime(time -
86400)), qq(\n);"
# Tomorrow at this same time (note addition)
$ perl -e "use POSIX qw(strftime); print strftime('%Y-%m-%d', localtime(time +
86400)), qq(\n);"This is really just a specific application of the recipes above, but is so common that it’s worth talking about by itself. See Figuring Out Date and Time Arithmetic for a handy table of values that may be of use.
“Date and Time String Formatting with strftime” in Appendix A
Read now
Unlock full access