1
Answer

how to set hours,minutes to my date

venkat

venkat

7y
152
1
i am trying to set hours,minutes and seconds but not able to do please help on this.
 
input:  07/21/2017 
 
here input mean :currValue="07/21/2017 " 
 
my current code is:
var today = new Date(currValue);
var myToday = new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.setHours(0), today.setMinutes(0));
 
output: 07/21/2017 06:32:56 AM
 
Answers (1)
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 7y
First it is not clear where is input coming from and where is output coming from.
 
Which time value you want to assign is not quite clear. 
 
If you just want current date use 'new Date()'.
 
If you already have all of the values with you construct a string in following format:
 
yyyy-MM-ddTHH:mm:ss and then use it to create a new date time variable, for example:
 
  1. var stringValue = '2017-07-21T06:32:56';  
  2. var dt = new Date(stringValue);  
  3. alert(dt);  
 
Hope it helps.