Create a custom date format for the DateTime Joomla! Module

Written on . Posted in .

Create a custom date format for the DateTime Joomla! Module

We’ve got many support tickets about how to add a custom date format in the DateTime Joomla! module. Below are three easy steps to create your own date format based in your Country.

For example, we want to display this date format “dddd, dd-mm-yyyy”, which is for Germany.

1. Open the file “/modules/mod_datetime/elements/dateformat.php”

FIND:

$date_formats_arr_a = array();

REPLACE WITH:

$date_formats_arr_a = array();
$date_formats_arr_a["dddd, dd-mm-yyyy"] = "dddd, dd-mm-yyyy (custom)";

2. Open the file “/modules/mod_datetime/helper.php”

FIND:

switch ($dateformat):

REPLACE WITH:

switch ($dateformat):
   case "dddd, dd-mm-yyyy":
   $date = $days[$day_of_the_week].", ".$d."-".$m."-".$year;
   break;

3. Save and upload the files. Then navigate to the module parameters and choose your new date format. Save the parameters, refresh your page, and now you have your custom date format using Web357’s DateTime Joomla! Module.

Custom date format - Screenshot from module parameters

Custom date format – Screenshot from module parameters