使用jQuery UI Datepicker时如何格式化日期,小时,分钟和秒? [英] How to format date with hours, minutes and seconds when using jQuery UI Datepicker?

查看:91
本文介绍了使用jQuery UI Datepicker时如何格式化日期,小时,分钟和秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 jQuery UI Datepicker 格式化日期以显示小时,分钟和秒?

Is it possible to format a date with jQuery UI Datepicker as to show hours, minutes and seconds?

这是我当前的模型:

$(function() {
    $('#datepicker').datepicker({ dateFormat: 'yyy-dd-mm HH:MM:ss' }).val();
});

<html>
<head>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
  <title>snippet</title>
</head>
<body>

  <input type="text" id="datepicker">

  <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
  <script src="https://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script>

当我打电话给 .datepicker({dateFormat:'yyy-dd-mm HH:MM:ss '})返回值为:

When I call .datepicker({ dateFormat: 'yyy-dd-mm HH:MM:ss' }) the returned value is:


201313-07-03 HH:July:ss

201313-07-03 HH:July:ss

这是 JSFiddle

推荐答案

$("#datepicker").datepicker("option", "dateFormat", "yy-mm-dd ");

对于时间选择器,你应该将时间戳添加到Datepicker,它将使用一个等效命令格式化。

For the time picker, you should add timepicker to Datepicker, and it would be formatted with one equivalent command.

编辑

使用这个扩展jQuery UI Datepicker。您可以同时选择日期和时间。

Use this one that extend jQuery UI Datepicker. You can pick up both date and time.

http://trentrichardson.com / examples / timepicker /

这篇关于使用jQuery UI Datepicker时如何格式化日期,小时,分钟和秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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