Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation split date from json data

    Hi,
    I have code like below, Where i tried to split the date,If something is wrong correct me. Please help me. Thanks in Advance


    Code:
        var viewModel = {
            dSource: ko.observable(),
            
                   
    
            onClick: function () {
                $.ajax({
                    type: 'POST',
                    url: 'http://www.mysite.com/data.php',
                    dataType: 'json',
                    success: function (data) {
                      
                       
    
                        var res = [];
                        for (var i in data) {
                            var rows = data[i];
                                   
                                
                                res.push({ 
                                 event_id: rows[0],
                                 event_name: rows[1],
                                 date: rows[2],
                                 venue:rows[3],
                                 url:rows[4],
                                    
                                 });
    
                           /* This is the part i am having problem */
    
                                var eventdate = $data.date;
                                var splitdate = eventdate.split("-");
                                year = splitdate[0],
                                month = splitdate[1],
                                day = splitdate[2]
                                if (month == 01) {
                                    month = "Jan"
                                }
                                if (month == 02) {
                                    month = "Feb"
                                }
    
                                if (month == 03) {
                                    month = "Mar"
                                }
    
                                var newDate = year - month - day;
    
                      /* Till This */
    
                         }
                        viewModel.dSource(res);
                    }
                });
            }
        };
    Last edited by vinyl-junkie; 09-18-2013 at 05:04 AM. Reason: added code tags


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •