DateTime format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

When I retrieve urn:schemas:httpmail:date field, how do I set the format
from VB.net code? I assume I should have several DateTime formats to choose
from.
Or is there any VB.net class to convert this field to a format I specify?
Thanks.

Li
 
Li said:
When I retrieve urn:schemas:httpmail:date field, how do I set the format
from VB.net code? I assume I should have several DateTime formats to choose
from.
Or is there any VB.net class to convert this field to a format I specify?
Thanks.
You can pass a DateTimeFormatInfo invariant to the the DateTime.ToString
method to specify the format.

Below is a table of format strings and the resulting date format.
d :08/17/2000
D :Thursday, August 17, 2000
f :Thursday, August 17, 2000 16:32
F :Thursday, August 17, 2000 16:32:32
g :08/17/2000 16:32
G :08/17/2000 16:32:32
m :August 17
r :Thu, 17 Aug 2000 23:32:32 GMT
s :2000-08-17T16:32:32
t :16:32
T :16:32:32
u :2000-08-17 23:32:32Z
U :Thursday, August 17, 2000 23:32:32
y :August, 2000
dddd, MMMM dd yyyy :Thursday, August 17 2000
ddd, MMM d "'"yy :Thu, Aug 17 '00
dddd, MMMM dd :Thursday, August 17
M/yy :8/00
dd-MM-yy :17-08-00

To format using one of the above date formats you can do this.

DateTime.Now.ToString("D",DateTimeFormatInfo.InvariantInfo) ' Gives:
Thursday, August 17, 2000

Remember that the result varies by culture.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
Back
Top