I have one date "2017-11-30 07:15:45.3520000", I want to convert this date to "2017-11-30T07:15:45.352Z". How to convert to this format in javascript.
            Asked
            
        
        
            Active
            
        
            Viewed 183 times
        
    -5
            
            
        - 
                    If you do not know yet what we expect of you before asking here, please go read [ask]. This shows no research effort at all. – CBroe Dec 01 '17 at 08:21
- 
                    2http://idownvotedbecau.se/noresearch/ Duplicate of https://stackoverflow.com/questions/2573521/how-do-i-output-an-iso-8601-formatted-string-in-javascript, probably several others. – T.J. Crowder Dec 01 '17 at 08:22
- 
                    Please take the [tour], have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) – T.J. Crowder Dec 01 '17 at 08:22
2 Answers
2
            var n = new Date("2017-11-30 07:15:45.3520000Z").toISOString();
    console.log(n);
add one "Z" to your time string. Eg: "2017-11-30 07:15:45.3520000Z"
 
    
    
        Saiju
        
- 350
- 2
- 8
1
            
            
        You can use toISOString method like this:
var date = new Date("2017-11-30 07:15:45.3520000");
console.log(date.toISOString()); 
    
    
        Sourabh Somani
        
- 2,138
- 1
- 13
- 27
 
    
    
        farkasnorbert90
        
- 41
- 4
- 
                    I have tried above code. But I'm getting "2017-11-30T01:45:45.352Z" this time. But I need "2017-11-30T07:15:45.352Z" time. – Naveen Dec 01 '17 at 09:11
