且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解析日期字符串

更新时间:2021-12-25 04:16:18

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


" ž。 F&QUOT。 <滋** @ 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 &LT;无************ @ planet.nl&GT;在消息中写道

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