急急急~~~

blueteeth_yl 2010-01-06 02:42:21
形如2009-12-25 9:00:00格式的字符串,我怎么取到9:00这个时间串~~
...全文
79 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
kensouterry 2010-01-06
  • 打赏
  • 举报
回复
顶!
于吉小妖 2010-01-06
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 herichcq 的回复:]
string.Format("yyyy-MM-dd hh:mm");
[/Quote]
herichcq 2010-01-06
  • 打赏
  • 举报
回复
string.Format("yyyy-MM-dd hh:mm");
特别 2010-01-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 huming_h 的回复:]
DateTime.Parse("2009-12-25  9:00:00").ToString("hh:mm")
[/Quote]
省事
yzx314 2010-01-06
  • 打赏
  • 举报
回复
去时间的时候后面加个.ToString("你想取的格式")
跟上楼的一样的 强制取
xray2005 2010-01-06
  • 打赏
  • 举报
回复
DateTime.Parse("2009-12-25 9:00:00").ToString("hh:mm")
liqiang427 2010-01-06
  • 打赏
  • 举报
回复
貌似上面取到的是"2009-12-25" "9:00:00",楼主可以再次对字符串"9:00:00"进行string.Split(':'),然后得到了"9" "00",自己拼一下就可以

例如:
string test = @"2009-12-25 9:00:00";

string [] testList = test.Split(' ');
if(testList.Length <= 0)
{
return;
}

testList = testList[1].Split(':');
if(testList.Length <= 0)
{
return;
}

string ret = testList[0] + ":" + testList[1];
zhujiazhi 2010-01-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 huming_h 的回复:]
DateTime.Parse("2009-12-25  9:00:00").ToString("hh:mm")
[/Quote]
up
blueteeth_yl 2010-01-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 occam 的回复:]
indexOf(" ")
lastIndexOf(":")
substring

...
[/Quote]

以这个为例吧:2009-12-25 9:00:00取出来9:00
cicigl 2010-01-06
  • 打赏
  • 举报
回复
DateTime.Parse("2009-12-25 9:00:00").ToString("hh:mm")正解
huming_h 2010-01-06
  • 打赏
  • 举报
回复
DateTime.Parse("2009-12-25 9:00:00").ToString("hh:mm")
不懂装懂 2010-01-06
  • 打赏
  • 举报
回复
label1.Text = DateTime.Now.ToShortTimeString();
occam 2010-01-06
  • 打赏
  • 举报
回复
indexOf(" ")
lastIndexOf(":")
substring

...
平生我自如 2010-01-06
  • 打赏
  • 举报
回复
有函数取字符串的阿
liqiang427 2010-01-06
  • 打赏
  • 举报
回复
string.Split(' ')

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧