Datetime columns

Video versionA video overview of datetime column in wpDataTables

Datetime columns in wpDataTablesDateTime column type and when to use it

The “Datetime” column type is used for values that contain both date and time segments. Datetime columns will render the date and time values in the format you specify on the plugin settings page.

  • Rendering rules: the value is cast as a date and time, and then formatted using the format defined in the plugin settings.
  • Sorting rules: datetime.
  • Applicable filter types: datetime range.
  • Issues to note:
    • When working with Excel files, it’s the best to set the format of Datetime columns as plain text since the PHPExcel library that parses Excel files does not parse the Excel date format correctly. This results in a wrong rendering of the dates (they usually get reset to 01/01/1970).
    • When you’re working with MySQL, please cast timestamps columns to datetime to avoid problems.
    • Global search doesn’t support search by datetime.

ExampleA demo table with DateTime columns

Date & Time” column in this table is of Datetime type.

Datetime Table

wdt_IDDate & timeHome teamAway teamStadium
122/10/2020 01:30 PMBournemouthTottenhamDean Court
222/10/2020 04:00 PMArsenalMiddlesbroughEmirates Stadium
322/10/2020 04:00 PMBurnleyEvertonTurf Moor
422/10/2020 04:00 PMHull CityStoke CityKCOM Stadium
522/10/2020 04:00 PMLeicester CityCrystal PalaceKing Power Stadium
622/10/2020 04:00 PMSwansea CityWatfordLiberty Stadium
722/10/2020 04:00 PMWest Ham UnitedSunderlandLondon Stadium
822/10/2020 06:30 PMLiverpoolWest Bromwich AlbionAnfield
922/10/2020 06:30 PMManchester CitySouthamptonEtihad Stadium
1022/10/2020 07:30 PMChelseaManchester UnitedStamford Bridge
Date & timeHome teamAway teamStadium

Datetime column settings

You may notice that in some cases when you create a table using “Create a table linked to an existing data source“, the “Datetime” column is not rendering well (Some cell values are missing). This happens when the plugin is unable to guess the format in which the Datetime is stored in the data source. In most cases it guesses correctly, but sometimes it is necessary to configure the input format manually. To do so, open the column settings for the column, go to the “Date” tab, and change the “Date input format” to match the format in the data source. This can happen for CSV, JSON, XML or Google Spreadsheet inputs, or if you are using Excel and store Datetime cells in plain text format.

Do you have the best

essential plugins installed?

Grab the best 46 plugins. Tested and sorted.

Plugins for SEO, Caching, Security, Design and UX, Stats & analytics, Social sharing. Only the best ones.

By clicking "subscribe" you consent that the information you provide via this form will be securely processed and stored in compliance with EU privacy laws (GDPR).

Thank you for subscribing! Please check your inbox to download the WordPress goodies.