Use ISOString for getFormattedDate (#15914)

Use `ISOString`
This commit is contained in:
SUZUKI Sosuke authored and GitHub committed 2024-01-13 03:42:19 +09:00
1 parent 0d9aa7b6af
commit 12f91dd1a9
1 file changed
+6 -3
+6 -3
View File
@@ -1,8 +1,11 @@
// TODO: Implement this in `utils.js` when jest.importActual is landed. // TODO: Implement this in `utils.js` when jest.importActual is landed.
export default function getFormattedDate() { export default function getFormattedDate() {
const date = new Date(); const date = new Date();
const year = date.getFullYear(); const isoStr = date.toISOString();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0"); const year = isoStr.slice(0, 4);
const month = isoStr.slice(5, 7);
const day = isoStr.slice(8, 10);
return { year, month, day }; return { year, month, day };
} }