Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom date and time format #41

Merged
merged 7 commits into from
Mar 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
i18n and customization of date time format for columns
  • Loading branch information
benoitchantre committed Feb 28, 2018
commit 408b79f4fe368687401b80427730363aee637d56
10 changes: 8 additions & 2 deletions inc/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,20 @@ function edit_event_columns( $columns ) {
*/
function manage_event_columns( $column, $post_id ) {

$set_dmy_format = apply_filters( 'be_event_set_dmy_format', false );
$date_format = apply_filters( 'be_event_columns_date_format', $set_dmy_format ? 'j M Y' : 'M j, Y' );

$set_24_hour_clock = apply_filters( 'be_event_set_24_hour_clock', false );
$date_time_format = apply_filters( 'be_event_columns_date_time_format', $set_24_hour_clock ? $date_format . ' (G:i)' : $date_format . ' (g:i A)' );

switch ( $column ) {

/* If displaying the 'Starts' column. */
case 'event_start' :

/* Get the post meta. */
$allday = get_post_meta( $post_id, 'be_event_allday', true );
$date_format = $allday ? 'M j, Y' : 'M j, Y g:i A';
$date_format = $allday ? $date_format : $date_time_format;
$start = get_post_meta( $post_id, 'be_event_start', true );

/* If no duration is found, output a default message. */
Expand All @@ -186,7 +192,7 @@ function manage_event_columns( $column, $post_id ) {

/* Get the post meta. */
$allday = get_post_meta( $post_id, 'be_event_allday', true );
$date_format = $allday ? 'M j, Y' : 'M j, Y g:i A';
$date_format = $allday ? $date_format : $date_time_format;
$end = get_post_meta( $post_id, 'be_event_end', true );

/* If no duration is found, output a default message. */
Expand Down