5
I have a piece of code that I can get the date and time, but the date is in the format Mês/Dia/Ano
followed by time, but precise in format Dia/Mês/Ano
followed by the time, I tried to change the shape but it was incorrect, look what I have:
Number.prototype.padLeft = function(base,chr){
var len = (String(base || 10).length - String(this).length)+1;
return len > 0? new Array(len).join(chr || '0')+this : this;
}
// Exibindo data no input ao iniciar tarefa
var d = new Date,
dformat = [ (d.getMonth()+1).padLeft(),
d.getDate().padLeft(),
d.getFullYear()
].join('-') +
' ' +
[ d.getHours().padLeft(),
d.getMinutes().padLeft(),
d.getSeconds().padLeft()
].join(':');
Note: the initial format is a timestamp.
It’s not just changing
(d.getMont()+1).padLeft()
withd.getDate().padLeft()
, nay?– Felipe Avelar
http://answall.com/a/22369/129
– Sergio
Hello @Felipe Avelar, I did this, but then appears to me the following: 04-2015 10:03:21, the day does not appear.
– adventistapr
@adventistapr, man I switched here the two and worked normal. Try to put
[d.getDate().padLeft(), (d.getMont()+1).padLeft(),...
in the first vector and see if it solves your problem...– Felipe Avelar