By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,954 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,954 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.