解析日期字符串 [英] parsing date string

查看:109
本文介绍了解析日期字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

i有格式的字符串

dd / mm / yyyyy hh:mm:ss

并将此作为输入DateTime.Parse给出的字符串不是

被识别为有效的日期时间格式字符串错误。

如何使解析方法接受我需要的格式化。 />
如果我执行console.writeLine DateTime.Now.ToString它给出的格式为:

YYYY-MM-DD HH:MM:SS


TIA,Z。


i have string in format
dd/mm/yyyyy hh:mm:ss
and giving this as an input to DateTime.Parse gives a string was not
recognized as a valid date time format string error.
how do i make the parse method to accept formating that i need.
if i do console.writeLine DateTime.Now.ToString it gives the format:
YYYY-MM-DD HH:MM:SS

TIA, Z.

推荐答案

您是否尝试过DateTime.ParseExact()?


" ž。 F"。 <滋** @ info-scopeREMSPAM.co.il>在消息中写道

新闻:uW ************** @ TK2MSFTNGP10.phx.gbl ...

HI,
i有格式的字符串

dd / mm / yyyyy hh:mm:ss

并将此作为DateTime.Parse的输入给出一个字符串不是

被认为是有效的日期时间格式字符串错误。

如何使解析方法接受我需要的格式化。

如果我执行console.writeLine DateTime.Now.ToString它给出的格式为:

YYYY-MM-DD HH:MM:SS


TIA,Z。

Did you try DateTime.ParseExact()?

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...

i have string in format
dd/mm/yyyyy hh:mm:ss
and giving this as an input to DateTime.Parse gives a string was not
recognized as a valid date time format string error.
how do i make the parse method to accept formating that i need.
if i do console.writeLine DateTime.Now.ToString it gives the format:
YYYY-MM-DD HH:MM:SS

TIA, Z.


ZF


dim mydate as DateTime = CDate(mydatestring)


我希望这有帮助


Cor
ZF

dim mydate as DateTime = CDate(mydatestring)

I hope this helps

Cor


是不是有一个简单的功能可以接受我的格式使用

(年/月/日)

i在MSDN中看到了一些用于管理文化和格式的复杂对象但是没有看到
没看到一种简单的方法,使用像sql转换函数的格式解析

允许。

i希望somene在这里发布一个解析日期的样本,并说明使用哪种格式




" Cor Ligthert <无************ @ planet.nl>在消息中写道

news:uF ************** @ TK2MSFTNGP10.phx.gbl ...
isn''t there a simple function that can accept the format i''m using
(dd/mm/yyyy )
i saw in MSDN some complex objects for managing the culture and format but
didnn''t see a simple way to parse using a format like sql convert function
allows.
i hope somene posts here a sample of parsing date and stating which format
to use.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
ZF

dim mydate as DateTime = CDate(mydatestring)

我希望这会有所帮助

ZF

dim mydate as DateTime = CDate(mydatestring)

I hope this helps

Cor



这篇关于解析日期字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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