如何格式化从数据库接收的日期和时间 [英] How do I format the date and time That is received from database

查看:359
本文介绍了如何格式化从数据库接收的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



日期:20100101(YYYY / MM / DD)
时间:120912(HH:MM: SS)



我必须格式化日期,如下所示:20100101 - >(2010-10-11)(看起来有) - 在年份和月份之间天



我必须格式化时间如下120912 - > 12:02:12假设我可能有时间从数据库62367



06:23:67

解决方案

我建议您使用以下方式转换数据: http://dev.mysql.com/doc/refman /5.1/zh/date-and-time-functions.html


Iam getting the date and time from Database as follows

Date : 20100101(YYYY/MM/DD) Time : 120912 (HH:MM:SS)

I have to format the Date as follows 20100101 --> (2010-10-11) (look to have ) "-" in between year and month and Day

I have to format the time as follows 120912 --> 12:02:12 suppose I may have the time as 62367 from the database

06:23:67

解决方案

I recommend you convert the data using: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

这篇关于如何格式化从数据库接收的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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