Skip to content

Problem with date format #704

Answered by Kheirah
donacrisante asked this question in Web
Aug 29, 2023 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

There are a couple of things you need to change.

  • The [id].js is in the wrong place. Move it from the pages folder down into the journey-list folder.
  • Change the routing accordingly in EntryList
<button onClick={() => router.push(`/journey-list/${entry.id}`)}>
    Edit
</button>
  • Change the initial value of the state in EntryForm
const [date, setDate] = useState(selectedEntry?.date || new Date());
  • Delete these lines in the handleSubmit of your EntryForm
const dateParts = newEntry.date.split("-");
const formattedDate = `${dateParts[2]}.${dateParts[1]}.${dateParts[0]}`;
newEntry.date = formattedDate;
  • Inside the EntryForm change the value of the date input field to this
value={date}

Thi…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Kheirah
Comment options

You must be logged in to vote
3 replies
@donacrisante
Comment options

@Kheirah
Comment options

@donacrisante
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants