DD / MM / YYY中的日期字段 [英] Date field in DD/MM/YYY

查看:89
本文介绍了DD / MM / YYY中的日期字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有


我在HTML表单上有一个日期字段,用户被要求键入

dd / mm / yyyy
但是,当写入MySql时,它不被接受或

另一个值在数据库中出现。


有没有将此字段的值更改回yyyymmdd格式的方法

在sql中正确接受。 ?更改应该最好是当用户点击提交时



有没有人知道这样做的任何代码/功能?


我正在使用PHP和HTML


谢谢

Jesmond

Dear all

I have a date field on a HTML form where the user is asked to key in
dd/mm/yyyy
However, when that is written to MySql it is either not accepted or
another value is tored in the database.

Is there any way to change value of this field back to yyyymmdd format
as accepted correctly in sql. ? The change should preferably be when
user click on submit.
Does anyone know of any code/function that does this ?

I''m using PHP and HTML

Thanks
Jesmond

推荐答案

Jes写道:
Jes wrote:

亲爱的所有


我在HTML表单上有一个日期字段,其中用户被要求输入

dd / mm / yyyy

但是,当写入MySql时,它不被接受或

另一个值已在数据库中出现。


有没有办法将此字段的值更改回yyyymmdd格式

在sql中正确接受。 ?更改应该最好是当用户点击提交时



有没有人知道这样做的任何代码/功能?


我正在使用PHP和HTML


谢谢

Jesmond
Dear all

I have a date field on a HTML form where the user is asked to key in
dd/mm/yyyy
However, when that is written to MySql it is either not accepted or
another value is tored in the database.

Is there any way to change value of this field back to yyyymmdd format
as accepted correctly in sql. ? The change should preferably be when
user click on submit.
Does anyone know of any code/function that does this ?

I''m using PHP and HTML

Thanks
Jesmond



Jesmond,

我在php中使用以下函数执行此任务。这使用户免于看到奇怪的日期。随意修改以满足您的需求。我在php中开始编写

这段代码所以它不是一个光滑的东西,但

它完成了这项工作,我不会整理好了。 (如果它没有

破了.......)


问候,

Chris Roy-Smith

<?php

//这个函数可以让sql日期对非逻辑日期用户可读...


函数toAdDate(

Hi Jesmond,
I use the following functions for this task in php. This saves the user from
seeing "strange dates". Feel free to modify to suit your needs. I wrote
this code while starting out in php so it''s not a slick as it could be, but
it does the job, and I havn''t got around to tidying it up. (If it aint
broke.......)

regards,
Chris Roy-Smith

<?php
//this function fort making sql dates readable to non-logical date users...

function toAusDate(


SQLDate){

if(
SQLDate){
if (


SQLDate == null){

返回null;

}
SQLDate==null){
return null;
}


这篇关于DD / MM / YYY中的日期字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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