Translate date in plugin-content-manager

Hello community,

strapi version: 3.1.6
OS: apple

I’ve tried to translate dates from the content manager plugin. I made a file called row.js in a folder extension as explained in the documentation.
When I use the command yarn develop --watch-admin I can see the modification
I’ve juste added .local() and add language in the initstate reducer.
return moment(date).locale(language).format(dateFormats[type]);

But when I build it, I don’t see the changes. Any ideas why don’t see changes ?
PS: It would be better to take the language from the strapi-admin select languages. Can I take the state from strapi-admin>languageProvider and use it in strapi-plugin-content-manager (maybe by importing the languageProviderReducer in the combine reducer of the plugin?)

Thanks

@soupette correct me if I’m wrong but don’t we already convert datetimes over to the users local time? I’m guessing there is a disconnect from the database where it’s set to the local time also but Strapi thinks it’s UTC.

Yes it’s better to convert it to the user’s local time if they are on different timezones.

sorry but i don’t get it … I use heroku postgres database where time is set in UTC. Datepicker and the datetime display in the customTable are in english . If I change the language of the backoffice it doesn’t modify the language of the datetime. That’s normal ?

Thanks

hi, is it possible to explain how to translate the date to another language ? i didn’t get your previous explanation @DMehaffy @soupette

@jeremy when you say “translate the date to another language” do you mean changing the format of the date like in French the 12th of October is written 12/10 whereas in US it’s 10/12 or do you mean changing the timezone?

@soupette I mean translate “monday 12th october” to “lundi 12 octobre”. I would also like to translate the datepicker week day and month.

Hello I have just shared a piece of answer that might help you here

Oh great thanks a lot for your help @soupette

On my front-end (connected to Strapi V4 back-end), I found this solution to display a french date format :

// INPUT
const date = '2023-09-19T12:12:24.261Z';

// FUNCTION
function convertToFrenchDate(date) {
    const dateSubString = date.substring(0, 10) // "2023-09-19"
	const splitDate = dateSubString.split("-") // ["2023", "09", "19"]
	const finalDate = `${splitDate[2]}-${splitDate[1]}-${splitDate[0]}` // "19-09-2023"
  	
  	return finalDate
  }


// OUTPUT
console.log(convertToFrenchDate(date))
// "19-09-2023"