转换日期格式 [英] converting a date format
问题描述
?
i有一个格式为mm / dd / yy的日期字符串。我希望将其转换为系统
默认格式。我这样做那样做吗?
reny
---
外出邮件已通过无病毒验证。
由AVG反查病毒系统( http://www.grisoft.com)。
版本:6.0.778 /病毒数据库:525 - 发布日期:15/10/04
?Hi,
i have a date string of format "mm/dd/yy".i want to convert it to systems
default format.how do i do that?
reny
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/04
推荐答案
使用DateTime.ParseExact()并在结果上调用ToShortDateString()(或任何方法)
。例如:
DateTime.ParseExact(" 01/10/04"," MM / dd / yy",Nothing).ToShortDateString()
" Reny J Joseph Thuthikattu" <重** @ bxtech.com>在消息中写道
news:u2 ************** @ TK2MSFTNGP12.phx.gbl ...
?
i的日期字符串格式为mm / dd / yy。我希望将其转换为系统
默认格式。我这样做吗?
reny
---
外发邮件经过无病毒认证。
由AVG反病毒系统检查( http://www.grisoft.com)。
版本:6.0。 778 /病毒库:525 - 发布日期:15/10/04
Use DateTime.ParseExact() and call ToShortDateString() (or any method) on
the result. Eg:
DateTime.ParseExact ("01/10/04", "MM/dd/yy", Nothing).ToShortDateString()
"Reny J Joseph Thuthikattu" <re**@bxtech.com> wrote in message
news:u2**************@TK2MSFTNGP12.phx.gbl...
?Hi,
i have a date string of format "mm/dd/yy".i want to convert it to systems
default format.how do i do that?
reny
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/04
Reny,
VBNet建议的方法是
dim mydate as datetime = CDate(mydatestring)
请记住,每次日期时间转换都需要进行全局设置
采用正确的日期时间格式。
我希望这有帮助吗?
Cor
" ; Reny J Joseph Thuthikattu < re ** @ bxtech.com>
Reny,
The VBNet advices method for that is
dim mydate as datetime = CDate(mydatestring)
Keep in mind that with every datetime conversion your globalsetting has to
be in the right datetime format.
I hope this helps?
Cor
"Reny J Joseph Thuthikattu" <re**@bxtech.com>
我有一个格式为mm / dd / yy的日期字符串。我希望将其转换为系统
默认我怎么做?
reny
i have a date string of format "mm/dd/yy".i want to convert it to systems
default format.how do i do that?
reny
" Reny J Joseph Thuthikattu" <重** @ bxtech.com> schrieb:
"Reny J Joseph Thuthikattu" <re**@bxtech.com> schrieb:
我有一个格式为mm / dd / yy的日期字符串。我希望将其转换为系统
默认格式。我这样做吗?
i have a date string of format "mm/dd/yy".i want to convert it to systems
default format.how do i do that?
阅读''DateTime.Parse'',''DateTime.ParseExact''和
''DateTime.ToString''的文档,这个页面:
日期和时间格式字符串
< URL: http://msdn.microsoft.com/library/en...nDateTimeForma
tStrings。 asp>
注意,在VB.NET中,''Date''指的是''DateTime''。
-
Herfried K. Wagner [MVP]
< URL:http://dotnet.mvps.org/>
Read the docs for ''DateTime.Parse'', ''DateTime.ParseExact'' and
''DateTime.ToString'', and this page:
Date and Time Format Strings
<URL:http://msdn.microsoft.com/library/en...nDateTimeForma
tStrings.asp>
Notice, that in VB.NET, ''Date'' refers to ''DateTime''.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
这篇关于转换日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!