不难的问题:求把操作系统短日期格式设置为(YYYY-MM-DD)格式的C#代码。 你把时间先读出来然后用substring分割然后重新组装 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static string GetPadDateTime(System.DateTime D) { string temp=D.Year.ToString()+"-"; if (D.Month<10) { temp+="0"+D.Month.ToString(); } else { temp+=D.Month.ToString(); } temp+="-"; if (D.Day<10) { temp+="0"+D.Day.ToString(); } else { temp+=D.Day.ToString(); } return temp; } public static string GetPadDateTime(string D) { return GetPadDateTime(System.DateTime.Parse(D)); }D 是传入的短时间格式日期或字符串 先谢谢两位,但我题目的意思是“假如操作系统原来的短日期格式是yy-m-d,我可以通过 控制面板->区域选项->日期->短日期->短日期格式 的方法把短日期格式设置为yyyy-MM-dd”,现在我需要通过C#代码来实现我刚才手工操作的过程。 你想做了windows?PFPF关注一下先 本人覺得改os的日期格式並不太好, 最好是將所寫的application system的日期格式設為你所需要的 'yyyy-MM-dd'. System.Datetime.Parse(strDateTime).ToShortDateString(); DateTime.Now.ToString("yyyy-MM-dd");-----------------可以的,我也这么用过 来晚了,,DateTime.Now.ToString("yyyy-MM-dd"); DateTime.Now.ToString("yyyy-mm-dd");没错的,放心用吧! list可以对写入数据进行筛选吗 如何将DatagGridView列标题设置为下拉列表 [求教]xml上添加节点 用IMessageFilter消息过滤拦截不到窗体失效消息(M_ACTIVATE, WM_NCACTIVATE) 请教关于Properties.Settings中的问题 关于 ListView key 键值的问题.... 跪求 关于C#MDI窗体加入控制面板的解决方法? 对c#中枚举的一些总结 送分题,在线等!!!! 问一些datagrid的初级问题 第一次用正版的编程软件,运气。 怎么用c# 做 公式管理器 ?
{
string temp=D.Year.ToString()+"-";
if (D.Month<10)
{
temp+="0"+D.Month.ToString();
}
else
{
temp+=D.Month.ToString();
}
temp+="-";
if (D.Day<10)
{
temp+="0"+D.Day.ToString();
}
else
{
temp+=D.Day.ToString();
}
return temp; }
public static string GetPadDateTime(string D)
{
return GetPadDateTime(System.DateTime.Parse(D));
}D 是传入的短时间格式日期或字符串
PFPF
关注一下先
-----------------
可以的,我也这么用过
没错的,放心用吧!