金铉Unity插件库 Unity版本2018.4.32f 目前包含本地化存储功能(根据类名存储读写),TCP客户端监听类型功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.5 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Globalization;
namespace JXSoft {
public class SystemDateUtil
{
public const string FULL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
public const string DATE_FORMAT = "yyyy-MM-dd";
public const string TIME_FORMAT = "HH:mm:ss";
public static string getFullDateMsg()
{
return DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss");
}
public static string getDayDateMsg()
{
return DateTime.Now.ToString("HH:mm:ss");
}
public static long getTimeStamp() {
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0);
return Convert.ToInt64(ts.TotalSeconds);
}
public static string getFullTimeFromTimeStamp(string timeStamp) {
DateTime dateTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
dateTime = dateTime.Add(toNow);
return dateTime.ToString("yyyy-MM-dd") + " " + dateTime.ToString("HH:mm:ss");
}
public static DateTime getDateTimeFromFullStr(string dateString, string formatString) {
DateTime dateTime = DateTime.ParseExact(dateString, formatString, CultureInfo.InvariantCulture);
return dateTime;
}
}
}