【c#-使用区域性信息将unix时间转换为特定的日期时间格式】教程文章相关的互联网学习教程文章

c#-使用区域性信息将unix时间转换为特定的日期时间格式【代码】

我尝试将字符串转换为特定的日期时间格式. 我有字符串:1431075600我尝试通过以下方式进行转换:private static IFormatProvider culture = new System.Globalization.CultureInfo("en-GB"); model.DeliveryDate = DateTime.Parse(data.DeliveryDate, culture, System.Globalization.DateTimeStyles.AssumeLocal);我收到错误消息:String was not recognized as a valid DateTime.最后,我想使用类似以下格式的日期时间Friday, 8 Ma...

javascript-日期时间格式从json到C#【代码】

我正在尝试解析从条带支付网关发送的json数据,并且json数据的datetime编码为数字.我试图将其解析为正确的.NET DateTime,但未成功. 你能让我知道怎么做吗? 复制了下面的json. 解决方法:在C#中,DateTimeOffset具有FromUnixTimeSeconds:// converts to UTC DateTimeOffset var dtOffset = DateTimeOffset.FromUnixTimeSeconds(1530291339); // if you need a DateTime you can var dt = dtOffset.UtcDateTime;// dtOffset.ToString(...

NPOI – 如何区分日期时间格式的数字Excel单元格(c#)【代码】

背景 我有一个Excel文件(xlxs),其中包含许多日期时间和小数,我想将其转换为二维字符串数组.数组中的字符串应该与用户将它们输入到excel中完全一致.为此,我使用NPO版本2.2.1和C#. 请注意,示例中的A列格式化为Excel中的日期!COLUMN A COLUMN B 2016-07-20 -46,95 2016-07-20 283,59 2016-07-20 -46,95 2016-07-20 52194,64我有一个泛型方法ConvertCellToString(),它将一个单元格转换为正确的字符串表示形式:private st...

c# – Tryparse日期时间字符串到日期时间格式【代码】

参见英文答案 > Converting a string to a DateTime with more than 7 decimals of milliseconds 2个我试图将“31.01.2017 07:56:29.470000000”日期时间字符串解析为datetime格式. 使用的代码:DateTime requiredDate;string date = "31.01.2017 07:56:29.470000000";DateTime.TryParseExact(date,"dd.MM.yyyy hh:mm:ss.fffffff",CultureInfo.InvariantCulture,DateTimeStyles.None,out req...

设置日期时间格式 – C#【代码】

我在用户控件中有以下属性:public DateTime? Value { get {return DatePickerInput.SelectedDate; } set { DatePickerInput.SelectedDate = value; } }这将按以下格式选择日期01-Feb-2012.我想更改格式,以便以dd / MM / yy格式返回日期……这怎么可能?解决方法:它使用您计算机上的当前文化设置.如果您需要该格式,则需要将其作为字符串返回,或者让接收方法将其转换为字符串.例如:string myFormat = Value.ToString("dd/MM/yyyy")...

c# – Linq to Sql – 日期时间格式 – YYYY-MMM(2009年3月)【代码】

我想编写一个Linq to Sql查询,它通过Username和DateTime进行计数和分组.我希望DateTime的格式如下“YYYY-MMM”(即2009年3月). 我认为这会工作,但Linq to Sql无法解析ToString“format”参数.dc.MyTable.GroupBy(r => new{Name = r.UserName,YearMonth = r.SomeDateTime.ToString("yyyy-MMM")}).Select(r => new{Name = r.UserName,YearMonth = r.YearMonth,Count = r.Count()}).OrderBy(r => r.YearMonth).ThenBy(r => r.Name);有没...