我正在与AngularJs合作开展一个项目。 这里我有3个html控件。
$scope.date
$scope.from
$scope.to
下面是html代码。
<form>
<div class="form-group row">
<label for="" class="col-sm-2 col-form-label">Set date</label>
<div class="col-sm-5">
<!-- <input type="email" class="form-control" id="inputEmail3" placeholder="Email"> -->
<datepicker date-format="yyyy-MM-dd" selector="form-control">
<div class="input-group">
<input class="form-control" placeholder="Choose a date" ng-model="date" id="date" />
<spam class="input-group-addon" style="cursor: pointer">
<i class="fa fa-lg fa-calendar"></i>
</spam>
</div>
</datepicker>
</div>
</div>
<div class="form-group row">
<label for="" class="col-sm-2 col-form-label">Set time</label>
<div class="col-sm-4">
<input type="time" class="form-control" placeholder="From" ng-model="from" id="from">
</div>
<label for="" class="col-sm-1 col-form-label">To</label>
<div class="col-sm-4">
<input type="time" class="form-control" placeholder="To" ng-model="to" id="to">
</div>
</div>
</form>
现在进行服务电话我需要通过日期时间,但此处我分别有日期和时间。
如何从以上可用数据构建日期时间和日期时间?
答案 0 :(得分:0)
您可以在控制器中的功能中组合日期。首先使用Date.prototype.toISOString()方法格式化日期/时间,然后使用String.prototype.substring()方法分别取datePart
和timePart
,最后合并两者以创建新{ {1}}实例。
Date