Dates API
This article will show you how to format dates in frontend and wp-admin. Note that the snippets posted below will work only with WPJobBoard 4.1.2 or newer.
Theory
Basically this comes down to two filters wpjb_date_display (all dates displayed in frontend go through this filter), wpjb_date_format (used for formatting dates in wp-admin). The dates are formatted using date patterns, you will find more about them in WordPress Codex.
Code Snippets
The code below will allow you to format any date in frontend excluding forms, the example below will change date format on Resumes Experience and Education from “M Y” to “Y/M”, if you wish to modify other dates as well you will need to similarly add $param[“format”] = “…” inside the “if” statement.
// Modify date format in the frontend add_filter("wpjb_date_display", "my_date_display"); function my_date_display($param) { if($param["format"] == get_option("date_format")) { // most of the dates in WPJB } elseif($param["format"] == "M, d") { // dates on jobs and resumes lists } elseif($param["format"] == "M Y") { // dates on resume Experience and Education $param["format"] = "Y/M"; } return $param; }
Modify dates in wp-admin panel and ALL forms.
add_filter("wpjb_date_format", "my_date_format"); function my_date_format($format) { return "d/m/Y"; }
Caution: in last example (“wpjb_date_format” filter) you should use only date patterns that will generate dates consisting from numbers only. In other words: “d/m/Y” is ok because it will generate date “20/05/1984”, “d F, Y” is incorrect because it will generate date in format “20 May, 1984”.
What file do I need to add the filter to to affect all the dates in the admin & the front-end? Adding it to my theme’s functions.php file doesn’t seem to do the trick…
Can you inform me what file I need to change so that in the list of vacancies the date will be 28 feb instead 28, feb
You should not need to change any of the files, it is best to create a new WordPress plugin and paste the code there or in very least open your theme functions.php file and add the code there.