angular
angular
jak w java script/nodejs uzyskać dzisiejszą datę plus godzine powiedzmy 17:00, program musi generować datetime który składa się z daty, dnia w którym uruchomiony jest program i do tego godzine 17:00
#javascript
#nodejs
  • Najlepsze
  • Wszystkie komentarze
q.....k
q.....k
zolwixx
@angular: yyyy

var teroz = new Date();
var zaroz = new Date().setDate(teroz.getFullYear(), teroz.getMonth(), teroz.getDate(), 17, 0, 0);
o to kamą?
p.....x
p.....x
@angular:

let d = new Date()
d.setHours(17)
Marmite
@zolwixx: Te nazwy zmiennych xD
angular
angular
angular Autor
0
@zolwixx: potrzebuje date aby pytać inny server o dane z ostatniej doby i tak codziennie
angular
angular
angular Autor
0
@phaux: a jak zrobić to samo tylko żeby jeszcze mieć date dzień wcześniej, chodzi o to aby pobierać dane z ostatnicg 24 godzin między 17 a 17
zolwixx
@angular:

var wczorej = new Date(zaroz.getDate() -1);
przy założeniu, że masz mój wcześniejszy kawałek kodu z teroz i zaroz ( ͡° ͜ʖ ͡°) albo jeśli za "zaroz" podstawisz phauxowe "d"

EDIT:
angular
angular
angular Autor
0
@zolwixx: dzięki wielki w nodejs jestem świeży a musze na tym robić bo server meteora słabo współpracuje z C#
angular
angular
angular Autor
0
@zolwixx: nie działa nie działa daje 1970 rok albo błąd
zolwixx
@angular: skrótowo coś podszedłem do tematu, w 2 byl blad, w 3 nie wiem czemu nie mozna zrobic .setDate na nowoutworzonym , tylko osobno. działający kod to:

var teroz = new Date();
var zaroz = new Date(teroz.getFullYear(), teroz.getMonth(), teroz.getDate(), 17, 0, 0);
var wczorej = new Date(zaroz);
wczorej.setDate(wczorej.getDate() -1);
DiKey
@angular: czyli coś źle to posklejałeś do kupy.
var date = new Date();
date.setDate(date.getDate() - 1);
date.setHours(17);
angular
angular
angular Autor
0
@DiKey: dzień cześniej nie działa tylko
musi być
var mili = zaroz.setMilliseconds(-86400000)
var wczorej = new Date(mili)