I'm using lightning-input type="datetime"
to take datetime input from a user inside a lightning web component. I initially bind the value returned from back-end to the input. It displays the correct date-time value fetched from back-end on the date-time picket.
However, when I call a js method on change of input, it fetches incorrect value.
So, in my case I'm displaying 12:00 PM to the user initially (fetched from back-end sfdc record). Now, if user updates the value to 12:15 PM, the handler updates the value on change. I use console to see the updated value and it displays 19:15 instead of 12:15 PM.. any idea why?
Below is the code snippet:
<lightning-input type="datetime"
label="Last Date"
value={endDate}
onchange={captureDateTimeChange}>
</lightning-input>
JS:
captureDateTimeChange(event){
console.log('DateTime : ' ,event.target.value);
}
Selected DateTime from datetime picker
Captured Date in js method:
What's causing the js method to pick incorrect date ?