469,603 Members | 2,329 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

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 4586
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
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.