The toISOString function toISOString responsible for converting your local date ( new Date ) to GMT.
If you do not want to use GMT then slice, you need to use the pure Date constructor and all getX functions, where X (days, month, year ...)
In addition, you need to expand the Number object with a function that helps you return 01 instead of 1 , for example, to save the format dd/mm/yyyy, hh/mm .
Let me name this prototype function AddZero
<input type="datetime-local" name="name" id="1234"> <script type="text/javascript"> Number.prototype.AddZero= function(b,c){ var l= (String(b|| 10).length - String(this).length)+1; return l> 0? new Array(l).join(c|| '0')+this : this; }</script>
Watch it
source share