问题保存日期到数据库mysql使用jquery datepicker [英] problem saving date to database mysql using jquery datepicker

查看:231
本文介绍了问题保存日期到数据库mysql使用jquery datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我使用的代码。

<script type="text/javascript">   
    $(document).ready(function(){     
            $("input#txtDate").datepicker({ altField: 'input#txtDate', altFormat: 'yy-dd-mm' }); 
    }); 

</script>

在将数据填充到适配器时显示此错误
无法将MySQL日期/时间值转换为System.DateTime
如何解决此问题。
我需要以格式显示gridview中的日期:
eg。 may-25 2011

at the time of filling the data to adapter it shows me this error "Unable to convert MySQL date/time value to System.DateTime" how to fix this. i need to show the date in gridview in this format: eg. may-25 2011

推荐答案

Datepicker和数据库是datetime类型的存储数据,输入字段是不被验证为正确的文本约会时间。在存储到数据库之前,使用以下方式将输入文本转换为datetime:

Datepicker and database are stored data of datetime type and input field is text which is not validated to be proper datetime. Before storing to database convert input text to datetime using:

$("input#txtDate").datepicker("setDate", $("input#txtDate").val())

这将正确地将输入字符串转换为datetime 。然后将数据库存入datetime类型的以下值:

This will correctly transform input string to datetime. Then store into database the following value of datetime type:

$("input#txtDate").datepicker().val()

或将其转换为所需的格式。

or convert it to desired format before.

这篇关于问题保存日期到数据库mysql使用jquery datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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