how to change the format of date that getting from database getting date from database showing some error. please check the image
getting date from database showing some error. please check the image
            Asked
            
        
        
            Active
            
        
            Viewed 130 times
        
    -1
            
            
         
    
    
        Shaggy
        
- 6,696
- 2
- 25
- 45
 
    
    
        kannan D.S
        
- 1,107
- 3
- 17
- 44
- 
                    What error are you getting ? – Dhrumil Nov 30 '15 at 11:17
- 
                    @ Matt Murdock alert shows the out put date format check my img – kannan D.S Nov 30 '15 at 11:19
- 
                    1What about some code? Some hints? I mean, what format do u use in your db (timestamp or date?) And on which layer do u want to change the format? – MorKadosh Nov 30 '15 at 11:19
- 
                    1@kannanD.S - Show us some code that you are currently using so that we can take it as a reference and help you out. – Dhrumil Nov 30 '15 at 11:21
- 
                    3Possible duplicate of [Converting .NET DateTime to JSON](http://stackoverflow.com/questions/1016847/converting-net-datetime-to-json) – Mosh Feu Nov 30 '15 at 11:23
- 
                    1what is it? date in miliseconds. – Jai Nov 30 '15 at 11:31
2 Answers
1
            
            
        try this
var date = new Date(parseInt(yourDate.substr(6)));
to format your date use the following code
 var parsedDate= new Date(date); 
var formattedDate =parsedDate.getDate()+"-"+parsedDate.getMonth()+"-"+parsedDate..getFullYear();
 
    
    
        Optimus
        
- 2,200
- 8
- 37
- 71
- 
                    @ Optimus thx i got a lond date format now, how to foramat that date to hour and minut – kannan D.S Nov 30 '15 at 11:37
0
            
            
        You could try this, assuming you can manipulate the 'date' you are getting from the database:
d = yourdate();
new_d = d.toUTCString();
There are also .toLocaleTimeString() (for times i.e., 11:11:12 am) and .toDateTimeString() (for days i.e., 11/11/2011)
 
    
    
        Kaushik Maheta
        
- 1,741
- 1
- 18
- 27
 
    
    
        rrd
        
- 5,789
- 3
- 28
- 36