首页 > UI-boostrap的datepicker获取是是GMT时间,如何转为string

UI-boostrap的datepicker获取是是GMT时间,如何转为string

例如:

    <input type="text" class="form-control" uib-datepicker-popup="{{format}}"
                   is-open="popup.opened3" datepicker-options="dateOptions" ng-required="true"
                   close-text="Close" alt-input-formats="altInputFormats" ng-focus="open3()" placeholder="实际装货时间"
                   ng-model="searchObject.sendTime"/>

但是获取的是:
finishTime
:
Fri Aug 19 2016 00:00:00 GMT+0800 (中国标准时间)

===========================================
但是如何获的:正常的string时间格式呢:看到什么获取什么就是什么,如图:2016-08-19

用的是anular,或者用js也行。


你看看这个是不是你要的效果
http://ngdemo.sinaapp.com/ng-...

我用requirejs+angularjs写的。
核心代码一样。

指令代码

/**
 * @author xialei <xialeistudio@gmail.com>
 */
define(["app"], function(app) {
    app.directive("datetimepicker", [function() {
        return {
            require: 'ngModel',
            link: function(scope, ele, attrs, ctrl) {
                //加载css
                var link = document.createElement('link');
                link.href = '/vendor/jquery.datetimepicker/jquery.datetimepicker.css';
                link.rel = 'stylesheet';
                document.body.appendChild(link);
                //加载js
                $.getScript( '/vendor/jquery.datetimepicker/jquery.datetimepicker.js', function() {
                    var options = {
                        lang: 'ch',
                        timepicker: !!attrs.timepicker,
                        format: attrs.format || (this.timepicker ? 'H:i' : 'Y-m-d H:i'),
                        onGenerate: function() {
                            scope.$apply(function() {
                                ctrl.$setViewValue(ele.val());
                            });
                        }
                    };
                    if(attrs.now) {
                        options.minDate = '-1970/01/01';
                    }
                    ele.datetimepicker(options);
                });
            }
        }
    }]);
});
<button type="button" ng-click="run()">Run</button>
<div>
    日期
    <input type="text" ng-model="date" placeholder="日期" datetimepicker="" format="Y-m-d"/>{{date}}
</div>
<div>
    时间<input type="text" ng-model="time" placeholder="时间" datetimepicker="" timepicker="true"/> {{time}}
</div>
define(["app"], function(app) {
    app.controller("HomeCtrl", ["$scope", function($scope) {
        $scope.run = function() {
            console.log('run');
        };
    }]);
});

我使用的时候,也没有在意这些,直接用下面的。你可以试试。

$( "input[name='endtime']" ).val();
【热门文章】
【热门文章】