Tuesday, April 28, 2009

轉換sql datetime為RFC 822格式

SET LANGUAGE 'English';
select  left(datename( dw, getutcdate() ), 3 )  + ', ' +convert( varchar(20), getutcdate(), 113 ) + ' GMT'
SET LANGUAGE 'Traditional Chinese'

由於使用的是'繁體中文'語系,再轉換前還需要將語系改為'英文'

 

附註: .net datetime轉RFC 822格式

DateTime today = DateTime.Now;
CulturInfo ci = new Culturinfo("en-US");
string rfc822 = today.ToString("ddd, dd MMM yyyy HH:mm:ss",ci)+" +0800";

No comments:

Post a Comment