如何在dd / mm / yyyy格式和mm / dd / yyyy格式的Javascript中比较两个日期(比如出生日期和当前日期)? [英] How to compare two dates (say Date of Birth with Current date) in Javascript in dd/ mm/yyyy format and mm/dd/yyyy format?
本文介绍了如何在dd / mm / yyyy格式和mm / dd / yyyy格式的Javascript中比较两个日期(比如出生日期和当前日期)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在dd / mm / yyyy格式和mm / dd / yyyy格式的Javascript中比较两个日期(比如出生日期和当前日期)?
How to compare two dates (say Date of Birth with Current date) in Javascript in dd/ mm/yyyy format and mm/dd/yyyy format?
推荐答案
以下是一些主题 -
如何使用JavaScript比较两个日期 [ ^ ]
http:/ /javascript.about.com/library/bltut19.htm [ ^ ]
Here are some threads -
How to Compare Two Dates Using JavaScript[^]
http://javascript.about.com/library/bltut19.htm[^]
DateTime Firstdate = new DateTime(2000,1,19,0,0,0,0);
DateTime Second = new DateTime();
天d = Days.daysBetween(Firstdate,Second);
int days = d.getDays(); < br $> b $ b
系统tem.out.println(区别+秒);
System.out.println(和+ Firstdate +是+天+天。);
DateTime Firstdate= new DateTime(2000, 1, 19, 0, 0, 0, 0);
DateTime Second= new DateTime();
Days d = Days.daysBetween(Firstdate, Second);
int days = d.getDays();
System.out.println(" Difference between " + Second);
System.out.println(" and " + Firstdate+ " is " + days + " days.");
您应该使用jQuery datepicker,原因如下:
1.无需编写代码来验证用户的日期输入(这是最大的麻烦);
2.可轻松定制的日期显示格式。
3.无服务器端往返。
根据需要调整以下代码:
You should use a jQuery datepicker for the following reasons:
1. No need to write code to validate users' inputs for date (that is the biggest hassle of all);
2. Easily customizable date format for display.
3. No server side round trips.
Adapt the following code to your need:
<!doctype html>
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
这篇关于如何在dd / mm / yyyy格式和mm / dd / yyyy格式的Javascript中比较两个日期(比如出生日期和当前日期)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文