I'm trying to translate the month name outputted by an ACF date field. How do I get the Spanish versions of those month names? Here's an example of my code:
$start_date = get_field('start_date');
$start_month = new DateTime($start_date);
$start_month = $start_month->format('M'); // "Oct", "Nov", etc.
The main problem, I think, is that the date is saved as a date rather than a string... So it seems to me that using something like wpml_register_single_string()
when the field is saved, is kind of pointless.
It seems like I should be telling the server to get the date in a different localization. I would envision the process to go something like this:
- WordPress retrieve's the ACF date from the database
- Based on the language set by the user (via WPML), we tell the server that we need the DateTime in that language/localization
- PHP outputs the date, translated appropriately
This seems logical to me, again, because we're not saving any strings to the database that should be translated. But, I'll be the first to admit, I don't have a clue what I'm doing here. Any help would be GREATLY appreciated!