{
    "mode": "perldoc",
    "parameter": "Time::ParseDate",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Time%3A%3AParseDate/json",
    "generated": "2026-06-12T12:31:31Z",
    "synopsis": "use Time::ParseDate;\n$secondssincejan11970 = parsedate(\"12/11/94 2pm\", NORELATIVE => 1)\n$secondssincejan11970 = parsedate(\"12/11/94 2pm\", %options)",
    "sections": {
        "NAME": {
            "content": "Time::ParseDate -- date parsing both relative and absolute\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Time::ParseDate;\n$secondssincejan11970 = parsedate(\"12/11/94 2pm\", NORELATIVE => 1)\n$secondssincejan11970 = parsedate(\"12/11/94 2pm\", %options)\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Date parsing can also use options. The options are as follows:\n\nFUZZY   -> it's okay not to parse the entire date string\nNOW     -> the \"current\" time for relative times (defaults to time())\nZONE    -> local timezone (defaults to $ENV{TZ})\nWHOLE   -> the whole input string must be parsed\nGMT     -> input time is assumed to be GMT, not localtime\nUK      -> prefer UK style dates (dd/mm over mm/dd)\nDATEREQUIRED -> do not default the date\nTIMEREQUIRED -> do not default the time\nNORELATIVE -> input time is not relative to NOW\nTIMEFIRST -> try parsing time before date [not default]\nPREFERPAST -> when year or day of week is ambiguous, assume past\nPREFERFUTURE -> when year or day of week is ambiguous, assume future\nSUBSECOND -> parse fraction seconds\nVALIDATE -> only accept normal values for HHMMSS, YYMMDD.  Otherwise\ndays like -1 might give the last day of the previous month.\n",
            "subsections": []
        },
        "DATE FORMATS RECOGNIZED": {
            "content": "",
            "subsections": [
                {
                    "name": "Absolute date formats",
                    "content": "Dow, dd Mon yy\nDow, dd Mon yyyy\nDow, dd Mon\ndd Mon yy\ndd Mon yyyy\nMonth day{st,nd,rd,th}, year\nMonth day{st,nd,rd,th}\nMon dd yyyy\nyyyy/mm/dd\nyyyy-mm-dd      (usually the best date specification syntax)\nyyyy/mm\nmm/dd/yy\nmm/dd/yyyy\nmm/yy\nyy/mm      (only if year > 12, or > 31 if UK)\nyy/mm/dd   (only if year > 12 and day < 32, or year > 31 if UK)\ndd/mm/yy   (only if UK, or an invalid mm/dd/yy or yy/mm/dd)\ndd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy)\ndd/mm      (only if UK, or an invalid mm/dd)\n"
                },
                {
                    "name": "Relative date formats:",
                    "content": "count \"days\"\ncount \"weeks\"\ncount \"months\"\ncount \"years\"\nDow \"after next\"\nDow \"before last\"\nDow                     (requires PREFERPAST or PREFERFUTURE)\n\"next\" Dow\n\"tomorrow\"\n\"today\"\n\"yesterday\"\n\"last\" dow\n\"last week\"\n\"now\"\n\"now\" \"+\" count units\n\"now\" \"-\" count units\n\"+\" count units\n\"-\" count units\ncount units \"ago\"\n"
                },
                {
                    "name": "Absolute time formats:",
                    "content": "hh:mm:ss[.ddd]\nhh:mm\nhh:mm[AP]M\nhh[AP]M\nhhmmss[[AP]M]\n\"noon\"\n\"midnight\"\n"
                },
                {
                    "name": "Relative time formats:",
                    "content": "count \"minutes\"         (count can be franctional \"1.5\" or \"1 1/2\")\ncount \"seconds\"\ncount \"hours\"\n\"+\" count units\n\"+\" count\n\"-\" count units\n\"-\" count\ncount units \"ago\"\n"
                },
                {
                    "name": "Timezone formats:",
                    "content": "[+-]dddd\nGMT[+-]d+\n[+-]dddd (TZN)\nTZN\n"
                },
                {
                    "name": "Special formats:",
                    "content": "[ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd]\nyy/mm/dd.hh:mm\n"
                }
            ]
        },
        "DESCRIPTION": {
            "content": "This module recognizes the above date/time formats. Usually a date and a time are specified.\nThere are numerous options for controlling what is recognized and what is not.\n\nThe return code is always the time in seconds since January 1st, 1970 or undef if it was unable\nto parse the time.\n\nIf a timezone is specified it must be after the time. Year specifications can be tacked onto the\nend of absolute times.\n\nIf \"parsedate()\" is called from array context, then it will return two elements. On successful\nparses, it will return the seconds and what remains of its input string. On unsuccessful parses,\nit will return \"undef\" and an error string.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "$seconds = parsedate(\"Mon Jan  2 04:24:27 1995\");\n$seconds = parsedate(\"Tue Apr 4 00:22:12 PDT 1995\");\n$seconds = parsedate(\"04.04.95 00:22\", ZONE => PDT);\n$seconds = parsedate(\"Jan 1 1999 11:23:34.578\", SUBSECOND => 1);\n$seconds = parsedate(\"122212 950404\", ZONE => PDT, TIMEFIRST => 1);\n$seconds = parsedate(\"+3 secs\", NOW => 796978800);\n$seconds = parsedate(\"2 months\", NOW => 796720932);\n$seconds = parsedate(\"last Tuesday\");\n$seconds = parsedate(\"Sunday before last\");\n\n($seconds, $remaining) = parsedate(\"today is the day\");\n($seconds, $error) = parsedate(\"today is\", WHOLE=>1);\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google, Inc. License hereby\ngranted for anyone to use, modify or redistribute this module at their own risk. Please feed\nuseful changes back to cpan@dave.sharnoff.org.\n",
            "subsections": []
        }
    },
    "summary": "Time::ParseDate -- date parsing both relative and absolute",
    "flags": [],
    "examples": [
        "$seconds = parsedate(\"Mon Jan  2 04:24:27 1995\");",
        "$seconds = parsedate(\"Tue Apr 4 00:22:12 PDT 1995\");",
        "$seconds = parsedate(\"04.04.95 00:22\", ZONE => PDT);",
        "$seconds = parsedate(\"Jan 1 1999 11:23:34.578\", SUBSECOND => 1);",
        "$seconds = parsedate(\"122212 950404\", ZONE => PDT, TIMEFIRST => 1);",
        "$seconds = parsedate(\"+3 secs\", NOW => 796978800);",
        "$seconds = parsedate(\"2 months\", NOW => 796720932);",
        "$seconds = parsedate(\"last Tuesday\");",
        "$seconds = parsedate(\"Sunday before last\");",
        "($seconds, $remaining) = parsedate(\"today is the day\");",
        "($seconds, $error) = parsedate(\"today is\", WHOLE=>1);"
    ],
    "see_also": []
}