Sidebar


Other Ways to Manipulate Dates

What if your database server doesn't let you format dates the way you want? Fortunately, there are several useful libraries that can help.

Perl

In Perl, you can use date-oriented modules. Date::Manip will parse dates in a bewildering variety of formats, and can perform many types of manipulations. Other modules, such as Date::Format and Date::Calc may be of interest as well. These modules can be found at www.perl.com/CPAN/modules/by-module/Date.

Python

Users of Python can look at the mxDateTime module. This useful module includes constructors for various date types, methods for formatting dates, and data types for measuring date spans. You can find the mxDateTime module at starship.python.net/~lemburg/mxDateTime.html.

Java

In Java, you can use the java.util.GregorianCalendar class to manipulate specific components (day, week, year, and so on) of a Date object. Also, the java.text.SimpleDateFormat class can parse or format dates for the current locale.

Other Languages

PHP includes a number of date-manipulation functions, which are documented in section XIII of chapter IV of the PHP manual (www.php.net/manual). C programmers can turn to the strftime(3) function to format date and time values. JavaScript includes the Date object. Danny Goodman's "JavaScript Date Object Techniques" includes some comprehensive information on the Date object. This article can be found at developer.iplanet.com/viewsource/goodman_dateobject.html. —BJ