最近做shopEX平臺訂單對接,因為shopEX是Php的,所以在提交訂單的時間格式首先轉換成unix時間格式,然后才能提交成功。 相同的,有response返回的所有的日期格式都是unix時間格式,所以要轉換成系統時間我們才能使用。 在網上搜了一下,整理了一下,下面是我用C#編寫的小例子,供各位參考。數據的嚴謹性,需要在實際使用時進行相應的判斷操作。 using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient;
namespace ConsoleApplication1 { /// <summary> /// unix與windowns日期格式互換 /// zhangyong 2012/03/07 /// </summary> class Program { private static readonly string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); static void Main(string[] args) { string DataStr = time; Program p = new Program(); string tempTime = p.ConvertToUnix(DataStr); string ssd = p.ConvertToWin(tempTime); }