转换为日期时间以保存到数据库 [英] Convert into datetime to save into Database

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

问题描述

我有一个类似这样的网站上的日期表

"2012年4月23日下午5:41:33 PDT"
我想将其保存到具有datetime字段的数据库中.

所以我的问题是如何将该日期格式保存到我的数据库中.

i have a datet comming from some website like this

"05:41:33 Apr 23, 2012 PDT"
i want to save it into my database which has a datetime field .

so my question is how can i save this dateformat into my database.

推荐答案

看看 ^ ].如果传递格式字符串,则可以重新创建DateTime.请注意,您所依赖的网站没有更改其格式,但这是不可避免的.
Have a look at DateTime.ParseExact[^]. If you pass the format string then you can recreate the DateTime. Note that you are relying on the website in question not changing its formatting, but that is inevitable.


您好,

U可以在数据库中使用Varchar()数据类型来保存它.而且,如果您想对此进行操作,则可以根据需要将其转换为特定格式.
Hi,

U can use Varchar() Datatype in database for saving it even. And if you want to do operation on that later convert it to specific format as you like.


这篇关于转换为日期时间以保存到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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