Skip to content

Instantly share code, notes, and snippets.

@suakig
Created April 20, 2015 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suakig/5347cdb71739f5b4f3c5 to your computer and use it in GitHub Desktop.
Save suakig/5347cdb71739f5b4f3c5 to your computer and use it in GitHub Desktop.
TimeSample.cs
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Cache;
using System.IO;
using System.Text.RegularExpressions;
public class TimeSample : MonoBehaviour
{
void Update()
{
if (Input.GetMouseButtonDown (0)) {
DateTime now = DateTimeNist.Now;
Debug.Log ("DateNistTime.Now " + now.ToString ("yyyy/MM/dd (ddd) HH:mm:ss") + "\n" +
"差分 " + (now - Load ()).TotalSeconds
);
Save (now);
}
}
void Save(DateTime now)
{
// 時刻の保存
PlayerPrefs.SetString ("DateNistTimeNow", now.ToBinary().ToString() );
PlayerPrefs.Save ();
}
DateTime Load()
{
string datetimeString = PlayerPrefs.GetString ("DateNistTimeNow", "0");
return System.DateTime.FromBinary (System.Convert.ToInt64 (datetimeString));
}
}
// Debug.Log ("DateTime.MinValue " + DateTime.MinValue.ToString("yyyy/MM/dd (ddd) HH:mm:ss"));//.ToBinary ().ToString ());
// Debug.Log ("DateTime.Now " + DateTime.Now.ToString("yyyy/MM/dd (ddd) HH:mm:ss"));//.ToBinary ().ToString ());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment