Adam Wohld


Date::FromToday - Calculate the date in the past or future X days from today


Version 0.05


Date::FromToday is a Perl module for calculating a date in the past or future X number of days from today. It allows for custom formatting of the date string with month/day/year placement, seperators, leading zeros, month translation, forcing today's date, number of digits in the year.

    use Date::FromToday;

    my $date = Date::FromToday->new( move => -1 );

    #  prints yesterdays date in MM_DD_YYYY
    print $date->date_string;


    my $date = Date::FromToday->new(
        move => -1,
        month_translator => [
                Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec
        date_string_format => '{M}.{D}.{Y}',
        leading_zeros => 0,
        year_digits => 2,

    #  prints yesterday's date looking like Jan.1.11
    print $date->date_string;



Creates and returns Date::FromToday object.

    my $date = Date::FromToday->new( move => -1 );

Here are the parms for Date::FromToday

  • move => $days_to_add_or_subtract

    Adds or subtracts days to the current date. Negative numbers move back in time, positive move into future. Required.

  • date_string_format => {M}_{D}_{Y}

    Decides on how to format the date_string method. M will be replaced by the Month, D with the Day, and Y with the Year. The delimiter is also configureable, M*D^Y = 12*31^2021

  • leading_zeros => [0|1]

    Determines if leading zeros will be added. Default = 1 which means it will be done.

  • month_translator => $month_names_list_ref

    Determines how the month will be displayed: month_translator => [ qw( Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec ), ],

  • force_today => MM_DD_YYYY

    You can also force the current date. Must be in MM_DD_YYYY format.

  • year_digits => [1|2|3|4]

    Specifies the number of digits in the year: 4 ~ 1895 3 ~ 895 2 ~ 95 1 ~ 5



Returns the calculated day, either numeric or translated from


Returns the calculated month


Returns the calculated year


Returns the date in a string as specified by the 'date_sting_format' param.


Adam Wohld, <adam at>


Please report any bugs or feature requests to bug-date-fromtoday at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Date::FromToday

You can also look for information at:


Copyright 2011 Adam Wohld.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.