[英]Combine datepicker and timepicker values with ngx-bootstrap
I am using ngx-bootstrap
in an Angular 5 project. 我在Angular 5项目中使用ngx-bootstrap
。 Does anyone know how to combine the Datepicker with Timepicker ? 有谁知道如何结合日期选择器与Timepicker ? When I select a time it always includes today´s date. 当我选择一个时间时,它总是包含今天的日期。 I want to use the date selected in the Datepicker
. 我想使用在Datepicker
选择的Datepicker
。
Even better would be to have it on the same model if possible. 如果可能的话,最好将它放在同一模型上。 The idea is to pass this into a webapi
which accepts a datetime
property(c#). 想法是将其传递到接受datetime
属性(c#)的webapi
中。
Thanks in advance! 提前致谢!
Both the values of Datepicker and Timepicker will be of type Date . Datepicker和Timepicker的值都将为Date类型。
So you can simply combine their values before sending the result to the server. 因此,您可以在将结果发送到服务器之前简单地合并它们的值。
For example, assuming that you stored the value of Datepicker inside a date
variable and the Timepicker inside the time
variable, you can do the following: 例如,假设您将Datepicker的值存储在date
变量中,并将Timepicker的值存储在time
变量中,则可以执行以下操作:
date.setHours(time.getHours(), time.getMinutes(), time.getSeconds());
now date
contains both the date from the Datepicker and the time frome the Timepicker, so you can now send date
to the server (in whatever format you need). 现在date
既包含Datepicker的日期,又包含Timepicker的时间,因此您现在可以将date
发送到服务器(所需的任何格式)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.