如何将timepicker的日期与当前时间进行比较 [英] how to compare date from timepicker with the current time

查看:142
本文介绍了如何将timepicker的日期与当前时间进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用timepicker()来获取日期和时间。现在我想知道那个时刻(日期+时间)是否已经过去了。你应该知道我将这些值通过ajax传递给我的控制器。所以我会把它们当作字符串。我怎样才能将这个字符串转换为日期,以便我可以比较它?

I use timepicker() to get both of the day and the time. Now I want to know if that moment(date+time) is already passed or not. You should know that I am passing these values to my controller with ajax. So I will get them as strings. How can I convert this string to date so that I can compare it ?

推荐答案

最简单的方法是,将日期时间变为毫秒,然后在服务器端进行比较。

The simplest way is, to convert the date and time into milliseconds and then comepare these on server side.

这篇关于如何将timepicker的日期与当前时间进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆