Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
139
rated 0 times [  146] [ 7]  / answers: 1 / hits: 31939  / 9 Years ago, mon, june 15, 2015, 12:00:00

I am using the next code to convert a date received from a MySQL database format 1993-10-23 00:00:00 and display it in spanish:



alert(moment('1993-10-23 00:00:00', 'YYYY-MM-DD', 'es')); 


23 oct is saturday. I would expect to get sábado but I get the next:



Sat Oct 23 1993 00:00:00 GMT+0200


Also tried adding: moment.locale('es-ES'); , moment.locale('en-ES'); and moment.locale('es');
but neither works.



What's the correct way of converting dates from a language to another?


More From » momentjs

 Answers
108

This seems to work, thanks @RobG



var localLocale = moment('1993-10-23 00:00:00');
moment.locale('es');
localLocale.locale(false);
alert(localLocale.format('LLLL'));

[#66204] Friday, June 12, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
donaldcristianl

Total Points: 114
Total Questions: 95
Total Answers: 110

Location: Bonaire
Member since Sat, May 27, 2023
1 Year ago
;