We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
toISOString
1 parent f92af84 commit 0ea2622Copy full SHA for 0ea2622
client-side-validation/app/routes/_index.tsx
@@ -26,16 +26,12 @@ export const loader = async () => {
26
const date = new Date();
27
28
// today string in "YYYY-MM-DD" format
29
- const todayString = `${date.getFullYear()}-${(
30
- "00" +
31
- (date.getMonth() + 1)
32
- ).slice(-2)}-${("00" + date.getDate()).slice(-2)}`;
+ const todayString = date.toISOString().substring(0, 10);
+
+ date.setDate(date.getDate() + 1)
33
34
// tomorrow string in "YYYY-MM-DD" format
35
- const tomorrowString = `${date.getFullYear()}-${(
36
37
38
- ).slice(-2)}-${("00" + (date.getDate() + 1)).slice(-2)}`;
+ const tomorrowString = date.toISOString().substring(0, 10);
39
40
return json({ todayString, tomorrowString });
41
};
0 commit comments