beyonk-group / svelte-datepicker

A lightweight datepicker written in Svelte
MIT License
143 stars 23 forks source link

One day behind/ahead #62

Open shadowempire123 opened 2 years ago

shadowempire123 commented 2 years ago

image


</script>
        import DatePicker from '@beyonk/svelte-datepicker/src/components/DatePicker.svelte'
    let selected
    let selected2
</script>

<main>
    <DatePicker range={true} time={true} on:range-selected={(e) => (selected = e.detail)} />
    <DatePicker range={false} bind:selected={selected2} on:range-selected={(e) => (selected = e.detail)} />
        <br />
    {JSON.stringify(selected)} <br />
    {JSON.stringify(selected2)}
</main>

fixed it with: $: selected2 = dayjs(selected2).add(1, 'day').toString() // fix 1 day offset

shadowempire123 commented 2 years ago

and time is offset 2 hours...

voneiden commented 2 years ago

Z means UTC time.

I'm assuming you were locally UTC+2 when you made this issue? In that case the behaviour is correct - 2022-08-31T22:00:00.000Z is equivalent to 2022-09-01T00:00:000+02:00.