472,118 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,118 software developers and data experts.

How to convert the email date in header to the date of vb.net?

yxq
Hello,

I found there are some date formats in the email header,

for example:
Fri, 23 Sep 2005 08:51:56 +0800
Sat, 17 Sep 2005 09:08:07
Wed Oct 19 13:40:23 2005
19 Oct 2005 13:40:23 +0000
19 Oct 2005 13:40:23 -0400

How to convert these date formats to VB.NET date? Thank you!
Nov 21 '05 #1
2 4789
Hello,

AFAIK, you'll have to use custom date & time format strings and
Date.ParseExact method for this, e.g. for first item in your list:

~
Dim dt As Date = Date.ParseExact("Fri, 23 Sep 2005 08:51:56 +0800",
"ddd, dd MMM yyyy hh:mm:ss zzzz",
Globalization.DateTimeFormatInfo.InvariantInfo)
~

See this for more info:

"Custom DateTime Format Strings"
http://msdn.microsoft.com/library/en...CustomDateTime
FormatStrings.asp

Roman
"yxq" <ga***@163.net> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå:
news:um**************@TK2MSFTNGP10.phx.gbl...
Hello,

I found there are some date formats in the email header,

for example:
Fri, 23 Sep 2005 08:51:56 +0800
Sat, 17 Sep 2005 09:08:07
Wed Oct 19 13:40:23 2005
19 Oct 2005 13:40:23 +0000
19 Oct 2005 13:40:23 -0400

How to convert these date formats to VB.NET date? Thank you!

Nov 21 '05 #2
yxq
I found a websit to convert email date format, can anyone convert to vb.net?
thank you!
http://search.cpan.org/~cwest/Email-.../Email/Date.pm

*************************************************
sub format_date {
my $time = shift || time;
my ($sec, $min, $hour, $mday, $mon, $year, $wday) = (localtime
$time)[0..6];
my $day = (qw[Sun Mon Tue Wed Thu Fri Sat])[$wday];
my $month = (qw[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec])[$mon];
$year += 1900;

my $diff = Time::Local::timegm(localtime $time)
- Time::Local::timegm(gmtime $time);
my $direc = $diff < 0 ? '-' : '+';
$diff = abs $diff;
my $tz_hr = int( $diff / 3600 );
my $tz_mi = int( $diff / 60 - $tz_hr * 60 );

sprintf "%s, %d %s %d %02d:%02d:%02d %s%02d%02d",
$day, $mday, $month, $year, $hour, $min, $sec, $direc, $tz_hr, $tz_mi;

}

"yxq" <ga***@163.net> дÈëÏûÏ¢ÐÂÎÅ:um**************@TK2MSFTNGP10.phx.gbl ...
Hello,

I found there are some date formats in the email header,

for example:
Fri, 23 Sep 2005 08:51:56 +0800
Sat, 17 Sep 2005 09:08:07
Wed Oct 19 13:40:23 2005
19 Oct 2005 13:40:23 +0000
19 Oct 2005 13:40:23 -0400

How to convert these date formats to VB.NET date? Thank you!

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Piotr Pietrowski | last post: by
6 posts views Thread by Mike Koerner | last post: by
4 posts views Thread by shapper | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.