본문 바로가기
개발/C#

유니티 C# 날짜 비교하기 DateTime.Compare

by SPNK 2023. 3. 29.
반응형
  • 코드 작성
using System;

public class DateComparer : MonoBehaviour
{
    public DateTime date1;
    public DateTime date2;

    void Start()
    {
        int result = DateTime.Compare(date1, date2);

        if (result < 0)
        {
            Debug.Log("date1 이 더 빠릅니다");
        }
        else if (result == 0)
        {
            Debug.Log("날짜가 같습니다");
        }
        else
        {
            Debug.Log("date2 가 더 빠릅니다");
        }
    }
}

 


참고할만한 글

 

유니티 C# 타이머 만들기 시분초 00:00:00 Timer

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Text timerText; public int timer = 0; private void Start() { StartCoroutine(TimerCoroution());

parksh3641.tistory.com

 

반응형

댓글