Skip to main content

How can I change the format of a date field?

Overview

You can change the format of a parsed date field using the Format Dates filter in Mailparser.

This is useful when you need to:

  • Standardize date formats (e.g., YYYY-MM-DD)
  • Prepare data for integrations or exports
  • Convert human-readable dates into machine-readable formats

How It Works

The Format Dates filter detects a date in your parsed data and converts it into a new format.

  • In most cases, Mailparser will automatically recognize the input format
  • If needed, you can manually define both the input format and output format

How to Use It

Step 1: Add the Filter

  1. Open your parsing rule
  2. Click Add Text Filter
  3. Navigate to:
    Refine Results → Format Dates


Step 2: Review Automatic Formatting

After adding the filter:

  • Mailparser will attempt to detect the date format automatically
  • A preview will show the converted result


Step 3: Set Custom Input and Output (Optional)

If the date is not recognized correctly:

  • Enter the input format (how the date appears in the email)
  • Enter the output format (how you want it formatted)

Example:

Input:

Tuesday, 29th August 2015

Input pattern:

l, jS F Y

Output pattern:

Y-m-d

Result:

2015-08-29



Format Syntax

Day Formatting Syntax

dDay of the month, 2 digits with leading zeros01 to 31
DA textual representation of a day, three lettersMon through Sun
jDay of the month without leading zeros1 to 31
l(lowercase 'L')A full textual representation of the day of the weekSunday throughSaturday
SEnglish ordinal suffix for the day of the month, 2 charactersst, nd, rd or th. Works well with j

Week Formatting Syntax

WISO-8601 week number of year, weeks starting on Monday Example:  42 (the 42nd week in the year)

Month Formatting Syntax

FA full textual representation of a month, such as January or MarchJanuary through December
mNumeric representation of a month, with leading zeros01 through 12
MA short textual representation of a month, three lettersJan through Dec
nNumeric representation of a month, without leading zeros1 through 12

Year Formatting Syntax

YA full numeric representation of a year, 4 digitsExamples:  1999 or 2003
yA two-digit representation of a yearExamples:  99 or 03

Time Formatting Syntax

aLowercase Ante meridiem and Post meridiemam or pm
AUppercase Ante meridiem and Post meridiemAM or PM
BSwatch Internet time000 through 999
g12-hour format of an hour without leading zeros1 through 12
G24-hour format of an hour without leading zeros0 through 23
h12-hour format of an hour with leading zeros01 through 12
H24-hour format of an hour with leading zeros00 through 23
iMinutes with leading zeros00 to 59
sSeconds, with leading zeros00 through 59

Other Formatting Options

timestampReturns the Linux timestamp (seconds since 1st Jan 1970)1449237286

These patterns follow the same syntax as the PHP date function.


Tips

  • Use a standard format like Y-m-d for better compatibility with other systems
  • Always check the preview to confirm correct formatting
  • If parsing fails, double-check your input pattern

Summary

The Format Dates filter allows you to convert parsed dates into a consistent and usable format.

It works automatically in most cases, but also gives you full control when custom formatting is needed.

Please note that the date filter can be applied to dates that are parsed from the content of the email. The filter is not available for the "received at" and "processed at" dates. Those two dates are generated by Mailparser and always come in a standard format and in the timezone you chose for your account.



 

 

Was this article helpful?
1 out of 3 found this helpful

Still stuck?

Send us your inbox name and a sample email.

Submit a request