不同类型的日期格式 [英] different types of date format

查看:90
本文介绍了不同类型的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我希望该用户可以在该字段中输入不同类型的日期格式,并且可以验证该格式并将其保存到数据库中.
$ dateFormat ="d-m-Y";

我希望用户也可以通过这种方式输入日期n
DD-MM-YYYY
DD/MM/YYYY
DDMMYYYY

如果其中任何一个有效,则将其保存到数据库中
plz help

hi
i want that user can enter different types of date format in the feild and i can validate the format and save it into database..

$dateFormat = "d-m-Y";

i want the user can enter date n this way also
DD-MM-YYYY
DD/MM/YYYY
DDMMYYYY

if any of one is validate is save it in to database
plz help

推荐答案

dateFormat ="d-m-Y";

我希望用户也可以通过这种方式输入日期n
DD-MM-YYYY
DD/MM/YYYY
DDMMYYYY

如果其中任何一个有效,则将其保存到数据库中
请帮助
dateFormat = "d-m-Y";

i want the user can enter date n this way also
DD-MM-YYYY
DD/MM/YYYY
DDMMYYYY

if any of one is validate is save it in to database
plz help


Ummm,这不是一个好的设计方法.在将数据存储到数据库之前,应将其标准化为单一格式.输入日期后,应验证日期,并将其转换为适当"格式,无论适当的格式是什么.
Ummm, that''s not a good design approach. The data should be normalized to a single format before storing it in the database. After they enter the date, it should be validated, and converted to the "proper" format, whatever that proper format is.


您实际上无法允许用户决定如何输入数据.接下来,您知道他们将要实际使用这些东西. :)

不过请认真考虑,在输入框的上方(或下方)添加一个标签,说明可接受的格式.例如日期为DD-MM-YYYY"或您所在的任何标准".它不必与数据库的格式相同,因为您可以在后台进行任何转换.
You really can''t allow users to decide how to enter data. Next thing you know they''ll want to actually use the stuff. :)

Seriously though, add a Label above (or below) the entry box stating the acceptable format. e.g. ''Date as DD-MM-YYYY'' or whatever the ''standard'' is where you are. It need not be the same as the format of your database since you can take care of any conversion behind the scenes.


这篇关于不同类型的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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