如何存储数据库日期格式:24-sep-12:HH:MM:SS
问题描述:
如何存储数据库日期格式:24-sep-12:HH:MM:SS(系统当前日期时间)
How store database date formate: 24-sep-12:HH:MM:SS (system current date time)
答
您使用的方法错误.数据库以其自己的格式存储日期.如果要使用它,则需要将其解析为DateTime以便存储在数据库中,并使用格式化程序以这种方式显示它.
您在这里拥有所有格式选项: http://msdn.microsoft.com/zh-cn/library/8kb3ddd4.aspx [ ^ ]
根据它,您需要这样的东西:"dd-MMM-yy:hh:mm:ss"
.并且不要忘记使用适当的语言环境来根据需要使用月份名称.
You are taking the wrong approach. The database is storing the dates in it''s own format. If you want to use this one, you need to parse it as DateTime to store in the database and use the formatter to display it this way.
You have all the formatting options here: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]
According to it you need something like this:"dd-MMM-yy:hh:mm:ss"
. And don''t forget to use the proper locale to have the month name as you need.