You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== parse_date ==
Copy Code
The output would be:
Copy Code
The output would be:
Parses a date string, and returns an integer timestamp representing that time. This essentially works in reverse of {{function|simple_date}}. The dateFormat string is the same as simple_date, see the documentation for that function to see full details on that. The dateString is the actual date to be parsed. The dateFormat should be the equivalent format that was used to generate the dateString. In general, this function is fairly lenient, and will still try to parse a dateString that doesn't necessarily conform to the given format, but it shouldn't be relied on to work with malformed data. Various portions of the date may be left off, in which case the missing portions will be assumed, for instance, if the time is left off completely, it is assumed to be midnight, and if the minutes are left off, it is assumed to be on the hour, if the date is left off, it is assumed to be today, etc.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| parse_date
|-
! scope="row" | Returns
| int
|-
! scope="row" | Usages
| dateFormat, dateString, [locale]
|-
! scope="row" | Throws
| [[../objects/ms.lang.FormatException|ms.lang.FormatException]]
|-
! scope="row" | Since
| 3.3.1
|-
! scope="row" | Restricted
| No
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
parse_date(dateFormat, dateString, [locale])=== Examples === ====Example 1==== Simple example Given the following code:
parse_date('yyMMddHHmmssZ', '130605114256-0500')

1 {{function|parse_date}}('yyMMddHHmmssZ', '130605114256-0500')
:1370450576000====Example 2==== Using the results of simple_date Given the following code:
@format = 'EEE, d MMM yyyy HH:mm:ss Z';
msg(parse_date(@format, simple_date(@format, 1)));

1 @format = 'EEE, d MMM yyyy HH:mm:ss Z';
2 {{function|msg}}({{function|parse_date}}(@format, {{function|simple_date}}(@format, 1)));
0===See Also===
[[API/functions/simple_date.html|simple_date]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)