Date: Sun, 31 Aug 2008 02:52:07 +0300 From: "Ivan \"Rambius\" Ivanov" <rambiusparkisanius@gmail.com> To: "FreeBSD Questions" <freebsd-questions@freebsd.org> Subject: Formatting dates to a specific pattern Message-ID: <89ce7f740808301652g169fa4d2v3fe5eff06100e31e@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello, I need to format the current date (as returned by date(1) ) to the pattern m-d-yyyy, where m is the month in one or digits, d is the day in one or two digits, and yyyy is the year in four digits. The problem for me is the day and the month, for example August should be 8, and not 08, and 5th of September should be 9-5-2008 and not 09-05-2008. I read the man page of date(1) but date(1) seems to always put leading zeros. I appreciate any help on how to format the date the way I want. In case you wonder why I need such a format: I am using a hosting company to run a web site. They are backing up my files in a .tar.gz archive and I can download it. The name of the backup archive contains the date formatted as I explained. I want to write a daily cron job script that will download the backup for me. Regards Rambius -- Tangra Mega Rock: http://www.radiotangra.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?89ce7f740808301652g169fa4d2v3fe5eff06100e31e>