If you wish to use perl to create a date/time stamp, well, there are a few gotchas. We'll show you one way to navigate the gotchas in this article. See this page for the technical details of the perl localtime function. Interestingly, we will focus on the date format of this very article. :) This also happens to be the default date/time stamp of MySQL. Notice that this format sorts correctly if you just strip out the non-digit characters. Here is a perl script that will create this:
The year portion is returned as the number of years since 1900. You also need to add 1 to the month because it starts at 0. The final gotcha is that the localtime function doesn't pad single digits with another zero. That is why we need to use the printf function with the %02d format option. This will force 4 digits for the year, and 2 digits for the other portions.
Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com