본문 바로가기
개발/C#

유니티 C# 시간 DateTime 출력하기 간단 사용법

by SPNK 2022. 7. 6.
반응형
  • 코드 작성
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);
    }
}

참고할만한 글

 

 

유니티 C# 카메라 흔들기 Camera Shake 간단 사용법

코드 작성 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public float shakeAmount = 3.0f; public float shakeTime = 1.0f; private void Start() { S

parksh3641.tistory.com

 

 

 

유니티 C# 오디오 Audio Source , Audio Clip 간단 사용법

코드 작성 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public AudioSource audioSource; public AudioClip audioClip; private void Start() { audio

parksh3641.tistory.com

 

반응형

댓글