我从xml document获取时间戳.现在,我想将Timestamp转换为Date格式(13-May-13)
XmlNodeList cNodes = xncomment.SelectNodes("comment");
foreach (XmlNode node in cNodes)
{
//I'm getting this "1372061224000" in comment-date
string comment_date = node["creation-timestamp"].InnerText;
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?提前致谢.
我在C#代码中遇到过以下函数:
Byte[] GetUNIXTimeStamp(DateTime dtVal)
{
if (m_bytTimeStamp == null) m_bytTimeStamp = new Byte[14];
Byte[] bytVals = BitConverter.GetBytes((UInt16)dtVal.Day);
m_bytTimeStamp[0] = bytVals[0];
m_bytTimeStamp[1] = bytVals[1];
bytVals = BitConverter.GetBytes((UInt16)dtVal.Month);
m_bytTimeStamp[2] = bytVals[0];
m_bytTimeStamp[3] = bytVals[1];
bytVals = BitConverter.GetBytes((UInt16)dtVal.Year);
m_bytTimeStamp[4] = bytVals[0];
m_bytTimeStamp[5] = bytVals[1];
bytVals = BitConverter.GetBytes((UInt16)dtVal.Hour);
m_bytTimeStamp[6] = bytVals[0];
m_bytTimeStamp[7] = bytVals[1];
bytVals = BitConverter.GetBytes((UInt16)dtVal.Minute);
m_bytTimeStamp[8] = bytVals[0];
m_bytTimeStamp[9] = bytVals[1];
bytVals = BitConverter.GetBytes((UInt16)dtVal.Second);
m_bytTimeStamp[10] = bytVals[0];
m_bytTimeStamp[11] = bytVals[1];
bytVals = BitConverter.GetBytes((UInt16)dtVal.Millisecond);
m_bytTimeStamp[12] = bytVals[0];
m_bytTimeStamp[13] = bytVals[1];
return m_bytTimeStamp;
} …
Run Code Online (Sandbox Code Playgroud) 本网站上有许多问题解释如何执行此操作.我的问题当我做什么似乎对其他人都有效时我没有得到正确的日期或时间.代码是......
long numberOfTicks = Convert.ToInt64(callAttribute);
startDateTime = new DateTime(numberOfTicks);
Run Code Online (Sandbox Code Playgroud)
值callAttribute
="1379953111"
转换后的值为numberOfTicks
= 1379953111
但结果DateTime
是startDateTime
={1/1/0001 12:02:17 AM}
我已经为ticks取了相同的值并在线转换它,它会提供正确的日期/时间.
我究竟做错了什么?
我正在尝试在Google Charts中显示一些数据,但会收到此错误:
Data column(s) for axis #0 cannot be of type string..
Run Code Online (Sandbox Code Playgroud)
我有这个类的两个属性:
public class GAStatistics
{
public string Date { get; set; }
public string Visitors { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我从这个控制器传递了这些属性的列表:
public class GAStatisticsController : Controller
{
//GET: /ShopStatistics/
public ActionResult GetData()
{
return Json(CreateCompaniesList(), JsonRequestBehavior.AllowGet);
}
private IEnumerable<GAStatistics> CreateCompaniesList()
{
List<GAStatistics> ListGaVisitors = new List<GAStatistics>();
foreach (var row in d.Rows)
{
GAStatistics GaVisits = new GAStatistics(row[0], row[1]);
ListGaVisitors.Add(GaVisits);
}
return ListGaVisitors;
}
}
Run Code Online (Sandbox Code Playgroud)
对于这个我从控制器传递列表的视图:
<script type="text/javascript" src="https://www.google.com/jsapi"></script> …
Run Code Online (Sandbox Code Playgroud) 对于一些构造函数或方法参数,有 date int 类型,例如: https://core.telegram.org/constructor/updateShortMessage updateShortMessage#d3f45784 id:int from_id:int message:string pts:int date:int seq:int = 更新;
有 date:int,一个十位整数,值例如:今天(2016 年 7 月 17 日星期日)的值为:1468782578,如何将 Telegram Api Core date:int 类型转换为 Java Date?谢谢你。
由于之前的雅虎财经下载 URL 不再有效,我现在只剩下这样的内容:
有谁知道 period1 (和 period2)如何转换为日期(反之亦然)
任何帮助表示赞赏!
谢谢!
我正在用java和json进行实验/学习.我正在尝试为json解析器创建自己的数据,我无法弄清楚它给我的示例数据是什么数据类型.我认为这是一个日期时间,但我不知道如何将我的日期(常规格式)转换为json日期格式.我正在使用PHP编写示例.
Jsonp示例数据:
[1110844800000,178.61],
[1110931200000,175.60],
[1111017600000,179.29],
Run Code Online (Sandbox Code Playgroud)
我的日期和数据格式:
2012-03-01 18:21:31,42
2012-03-01 18:22:31,46
2012-03-02 18:21:31,40
Run Code Online (Sandbox Code Playgroud)
有谁知道上面的13位数日期/时间json是特定于java还是json的日期时间?如果是这样,如何将我的数据转换为该格式?
谢谢!
我试图 在DateTime中转换此unix时间戳 1415115303410,这样:
private static DateTime UnixTimeStampToDateTime(long unixTimeStamp)
{
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp);
return dtDateTime;
}
Run Code Online (Sandbox Code Playgroud)
但是我的日期错了: 日期:{04/11/0045 00:00:00}
注意:dtDateTime.AddSeconds(unixTimeStamp)抛出异常..我的数字以毫秒为单位.
使用此在线转换工具http://www.epochconverter.com/我得到了正确的转换:
04/11/2014 15:35:03 GMT + 0:00
我怎么能改变这个呢?
ajax 请求发送 WCF 格式的日期值?它是一个转换为字符串的 JavaScript 日期对象,WCF 可以使用 DataContractSerializer 进行反序列化。
"/Date(1342210377000)/"
Run Code Online (Sandbox Code Playgroud)
客户端过去将此数据发送到 WCF 服务,但现在将其发送到 asp.net mvc 控制器。有谁知道如何将该字符串反序列化为 ac# DateTime 而不执行一系列 string.replace 操作?是否有我可以利用的现有 .NET 序列化器?我研究过使用 DataContractSerializer,但它的 readobject 方法需要一个流或 xmlreader。我无法弄清楚如何将 modelbindercontext.valueprovider 值转换为序列化器可以使用的流对象。如果有人知道我如何正确转换该字符串,我很想学习如何转换。感谢您提供任何提示、技巧、代码、链接等...
我得到了开始时间634942626000000000
和结束时间634942638000000000
.如何将其转换为Unix时间戳?我想在PHP中显示格式化的日期/时间?