NG_/Scripts/UI/头部/DisplayDate.cs
2024-12-13 18:49:44 +08:00

31 lines
634 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class DisplayDate : MonoBehaviour
{
public TextMeshProUGUI text;
public string format;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// 获取当前日期
DateTime currentDate = DateTime.Now;
// 格式化为 xxxx年xx月xx日 的格式
string formattedDate = currentDate.ToString(format);
// 显示日期
text.text = formattedDate;
}
}