Assuming that your date format – for whatever reason – really is yymmdd
instead of being set to what you defined in the admin settings section:
There’s the native PHP function date_parse_from_format()
that you can use in conjunction with the core setting. Just add the following plugin and use the custom Template Tag in your templates.
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: Real Date Template Tag
*/
function wpse85476_to_real_date( $date, $format )
{
static $date_format;
empty( $date_format ) AND $date_format = get_option( 'date_format' );
$date_parts = date_parse_from_format(
$format
,$date
);
// Error handling
if ( 0 < $date_parts['error_count'] )
{
return current_user_can( 'manage_options' )
? new WP_Error(
'date'
,'Wrong date format. Adjust Date Parser.'
,$date
)
: $date;
}
return array(
'date_parts' => $date_parts
,'real_date' => date_i18n(
$date_format
,mktime( 0, 0, 0, $date_parts['month'], $date_parts['day'], $date_parts['year'] )
)
);
}
Here’s how you’d retrieve a properly formatted date.
$date = wpse85476_to_real_date( get_field( 'data_nasterii' ), 'yymmdd' );
$real_date = $date['real_date'];
And here’s how you would retrieve the parts for calculation:
$date_parts = $date['date_parts'];