datejs 不会解析我的日期
我正在尝试解析芬兰日期,例如。 1990 年 3 月 13 日。 Javacript 不会这样做,但我发现 DateJS 应该可以。
我在我的项目中实现了 DateJS,但它仍然无法工作!
这是代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pick the date</title>
<link type="text/css" href="css/smoothness/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script src="inc/date-fi-FI.js" type="text/javascript"></script>
<script type="text/javascript">
function parseDate() {
var date = $('#date').val();
var parsedDate = Date.parse(date);
alert('Parsed date: '+parsedDate);
}
</script>
</head>
<body>
<form>
<input type="text" name="date" id="date" value ="13.03.1990" />
<input type="button" onclick="parseDate()" value="Parse the date" />
</form>
</body>
</html>
I am trying to parse a FINNISH date eg. 13.03.1990. Javacript won't do this but I found DateJS that should be able to.
I implemented DateJS into my project but it still won't work!
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pick the date</title>
<link type="text/css" href="css/smoothness/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script src="inc/date-fi-FI.js" type="text/javascript"></script>
<script type="text/javascript">
function parseDate() {
var date = $('#date').val();
var parsedDate = Date.parse(date);
alert('Parsed date: '+parsedDate);
}
</script>
</head>
<body>
<form>
<input type="text" name="date" id="date" value ="13.03.1990" />
<input type="button" onclick="parseDate()" value="Parse the date" />
</form>
</body>
</html>
Try it for yourself: http://resk.latvalashop.com/date.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只是有一个损坏的链接。您的测试页面未加载 DateJS 文件;我收到 404 错误
它正在寻找的 URL 是 http://resk.latvalashop .com/inc/date-fi-FI.js 但这不存在
You just have a broken link. You test page doesn't load the DateJS file; I get a 404 error instead
The URL it's looking for is http://resk.latvalashop.com/inc/date-fi-FI.js but that doesn't exist
@Flambino 是正确的,链接已失效。使用工作链接测试相同的代码,您的代码将按预期工作。
@Flambino is correct, the link is dead. Testing the same code with a working link and your code works as expected.