jQuery UI datepicker中的getDate方法之后进行解析 [英] parsedate after getDate method in jquery UI datepicker

查看:99
本文介绍了jQuery UI datepicker中的getDate方法之后进行解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有以下代码:

   $('#cal').datepicker({
                    onSelect: function(dateText, inst) { 
      var dateAsString = dateText; //the first parameter of this function
      var dateAsObject = $(this).datepicker( 'getDate' ); //the getDate method

   }
                });

我想知道如何在dateAsObject上调用parseDate以将其格式化为:YYYY/MM/DD.要存储到mysql DATE字段中

I wanted to know how I can call parseDate on dateAsObject to format it as such: YYYY/MM/DD. To store into mysql DATE field

推荐答案

JavaScript中没有直接的日期格式化程序.您可以使用任何jQuery插件按照所需的格式格式化日期,也可以只使用此代码来获取按要求格式化的日期.

There is no direct date formatter in JavaScript. You can either use any jQuery plugin to format the date as per your required format or you can just use this code to get the date formatted as per your requirement.

dateAsObject.getFullYear()+"/"+(dateAsObject.getMonth()+1)+"/"+ dateAsObject.getDate()

这篇关于jQuery UI datepicker中的getDate方法之后进行解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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