javascript date object issue in Safari and IE

后端 未结 5 1677
广开言路
广开言路 2020-12-16 03:02

I am taking a date from a JSON object in the format of 2012-12-31 and trying to convert it into friendly values and output it.

    var redeemableDate = item.         


        
5条回答
  •  醉梦人生
    2020-12-16 03:28

    Combining jacks and joe larson's response, the following code worked well for me:

            $scope.formatDate = function(date){
                    var date = date.split("-").join("/");
                    var dateOut = new Date(date);
                    return dateOut;
            }; 
    

    works well for Chrome and Safari... :)
    Thanks Jack and joe larson!!!

提交回复
热议问题