如何在.ics附件中显示24小时格式的日期时间 [英] How to display date time 24 hours format in .ics attached file
问题描述
大家好,
我试图通过创建ics文件和来自C#代码的电子邮件将.ics文件作为附件发送给用户。我能够将ICS文件保存到本地驱动器并附加到电子邮件。我需要24小时格式的开始时间和结束时间。
我创建了这样的.ics文件
String [] contents = {BEGIN:VCALENDAR,
PRODID: - // Flo Inc.//FloSoft//EN,
BEGIN:VEVENT,
DTSTART:+ DateTime.Now,
DTEND:+ DateTime.Now,
LOCATION:+ schLocation,
DESCRIPTION; ENCODING = QUOTED-PRINTABLE:+ emailContentVM.CalendarBody,
SUMMARY:+ strSubjectText,PRIORITY:3 ,
END:VEVENT,END:VCALENDAR};
System.IO .File.WriteAllLines(System.Web.HttpContext.Current.Server.MapPath(@〜\Content\Images\CrewHub\TASAuth.ics),内容);
emailContentVM.FileName =TASAuth.ics;
emailContentVM.ContentType =text / calendar; charset = utf-8;
string strContent = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(@〜\Content\Images\CrewHub\TASAuth.ics) );
emailContentVM.Content = strContent;
string strEmailResponce = SendEmailWithCalendarAttachement(emailContentVM);
return strEmailResponce ;
使用上面的代码获得
开始时间:2015年1月27日星期二5:30 Pm
结束时间:2015年1月27日下午6:30
我需要这样出来
Hi all,
I am trying to send .ics file as an attachment to user by creating ics file and email from C# code it self.I am able to send ICS file saving in to a local drive and attaching to email. I need start time and end time 24 hours format.
I created .ics file like this
String[] contents = { "BEGIN:VCALENDAR",
"PRODID:-//Flo Inc.//FloSoft//EN",
"BEGIN:VEVENT",
"DTSTART:" +DateTime.Now,
"DTEND:" + DateTime.Now,
"LOCATION:" + schLocation,
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + emailContentVM.CalendarBody,
"SUMMARY:" + strSubjectText, "PRIORITY:3",
"END:VEVENT", "END:VCALENDAR" };
System.IO.File.WriteAllLines(System.Web.HttpContext.Current.Server.MapPath(@"~\Content\Images\CrewHub\TASAuth.ics"), contents);
emailContentVM.FileName = "TASAuth.ics";
emailContentVM.ContentType = " text/calendar; charset=utf-8";
string strContent = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(@"~\Content\Images\CrewHub\TASAuth.ics"));
emailContentVM.Content = strContent;
string strEmailResponce = SendEmailWithCalendarAttachement(emailContentVM);
return strEmailResponce;
using above code am getting
start time : Tue 1/27/ 2015 5:30 Pm
End time: Tue 1/27/2015 6:30 pm
I need out put like this
start time : Tue 1/27/ 2015 5:30
End time: Tue 1/27/2015 6:30
i需要时间24小时格式,请帮助我。
谢谢,
Ram
i need time 24 hours format , plz kindly help me.
Thanks,
Ram
推荐答案
阅读以下内容: http://www.dotnetperls.com/datetime-format [ ^ ]
Read the following : http://www.dotnetperls.com/datetime-format[^]
您可以这样做:
For your special requirement you can do like this:
CultureInfo ci = new CultureInfo("en-US");
string dateTimeString = DateTime.Now.ToString("ddd d/M/yyyy h:mm", ci);
这篇关于如何在.ics附件中显示24小时格式的日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!