Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thibaut-decherit/0e5324147cfa315f7bb8a6d0084a91c7 to your computer and use it in GitHub Desktop.
Save thibaut-decherit/0e5324147cfa315f7bb8a6d0084a91c7 to your computer and use it in GitHub Desktop.
Date and DateTime format syntaxes

flatpickr

Follow this documentation: https://flatpickr.js.org/formatting/

You probably want something like Y-m-d H:i:S, adapt as needed.

Do NOT use m for minutes, it's for months.

PHP (Symfony DateTimeType form input 'format' option)

Follow this documentation: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax

You probably want something like y-MM-dd HH:mm:s, adapt as needed.

Do NOT use https://www.php.net/manual/en/datetime.format.php syntaxes. Potential traps:

  • Y for year, which tends to have a 1 year offset
  • D for day of the month (it's for a 3 letters textual representation in that documentation but anyway), which is for day of the year, so if your test date is in January you won't notice anything wrong.

PHP (Twig |date(), DateTime::format()...)

Follow this documentation: https://www.php.net/manual/en/datetime.format.php

You probably want something like Y-m-d H:i:s, adapt as needed.

Do NOT use m for minutes, it's for months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment