반응형
- 코드 작성
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
DateTime today;
DateTime now;
private void Start() //날짜 디버그 출력
{
today = System.DateTime.Today;
now = System.DateTime.Now;
Debug.Log(today.ToString("yyyy-MM-dd"));
Debug.Log(now.ToString("yyyy-MM-dd-hh-mm-ss"));
}
void AddDateTime() //날짜 더하거나 빼기
{
today = System.DateTime.Today.AddYears(1);
today = System.DateTime.Today.AddMonths(1);
today = System.DateTime.Today.AddDays(1);
today = System.DateTime.Today.AddHours(1);
today = System.DateTime.Today.AddMinutes(1);
today = System.DateTime.Today.AddSeconds(1);
}
void CompareDateTime(DateTime target) //날짜 비교
{
TimeSpan span = target - now;
Debug.Log("날짜 차이 : " + span.TotalSeconds);
}
}
참고할만한 글
반응형