I am from Thailand, and wondering is there a way to reverse a format in date-fns?
For example, this function will turn "2022-09-24" to "saturday-24-september-2564"
This there a good method using date-fns to create a new function that will turn "saturday-9-september-2564" back to "2022-09-24"?
Thank you so much in advance
//----------------
import format from "date-fns/format";
import th from "date-fns/locale/th";
import addYears from "date-fns/addYears";
const transformDate = (d) => {
const newDate = new Date(d);
const year_ymd = addYears(newDate, 543);
const urlText =
format(newDate, "EEEE'-'d'-'MMMM") + format(year_ymd, "'-'yyyy");
return urlText.toLowerCase();
};
transformDate(2022-09-24);
