如何截取这个时间字符串?

[复制链接]
查看11 | 回复4 | 2010-7-14 14:16:33 | 显示全部楼层 |阅读模式
2010-08-06.
取出 8
2010-11-13
取出 11
取出月份,注意是1到12之间的数字,不是01样式的。
是c#。 2010-08-06不是时间类型,是字符串类型。

回复

使用道具 举报

千问 | 2010-7-14 14:16:33 | 显示全部楼层
DateTime t = Convert.ToDateTime('2010-08-06');int month=t.Month;先专程时间类型,再取出月
回复

使用道具 举报

千问 | 2010-7-14 14:16:33 | 显示全部楼层
string str = "2008-08-06";int result = int.Parse(str.Split('-')[1]);
回复

使用道具 举报

千问 | 2010-7-14 14:16:33 | 显示全部楼层
string time="2010-08-06":string ls_time=time.subString(6,1);string time="2010-11-13";string []ls_time1=time.spit('-');string ls_time=ls_time1[1];
回复

使用道具 举报

千问 | 2010-7-14 14:16:33 | 显示全部楼层
你使用的是什么语言 vb c# java中都有,然后int一下 或者转化一下 应该就可以取到1-12之间的数字了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行