I am currently pulling a date from a users meta and making it so I can input a shortcode and it will show that date in certain places. I have the following code written and it works great!
function delivery_date( $atts ) {
global $current_user, $user_login;
get_currentuserinfo();
add_filter('widget_text', 'do_shortcode');
if ($user_login)
return $current_user->delivery_date ;
}
add_shortcode( 'delivery_date', 'delivery_date' );
Now, my problem is that the date is showing up at Y-m-d (2019-09-25) but I want it to show up as d-m-Y (09-25-2019). What is the best way to do this? What do I need to add to my code and where? All help is much appreciated! Thank you!
I am currently pulling a date from a users meta and making it so I can input a shortcode and it will show that date in certain places. I have the following code written and it works great!
function delivery_date( $atts ) {
global $current_user, $user_login;
get_currentuserinfo();
add_filter('widget_text', 'do_shortcode');
if ($user_login)
return $current_user->delivery_date ;
}
add_shortcode( 'delivery_date', 'delivery_date' );
Now, my problem is that the date is showing up at Y-m-d (2019-09-25) but I want it to show up as d-m-Y (09-25-2019). What is the best way to do this? What do I need to add to my code and where? All help is much appreciated! Thank you!
Share Improve this question asked Sep 25, 2019 at 9:15 Coleman SmithColeman Smith 31 bronze badge1 Answer
Reset to default 0Try with change line to date('d-m-Y',strtotime($current_user->delivery_date)) ;
function delivery_date( $atts ) {
global $current_user, $user_login;
get_currentuserinfo();
add_filter('widget_text', 'do_shortcode');
if ($user_login)
return date('d-m-Y',strtotime($current_user->delivery_date)) ;
}
add_shortcode( 'delivery_date', 'delivery_date' );
echo do_shortcode('[delivery_date]');