NG_/Assets/Scripts/UI/头部/DisplayDayOfWeek.cs

29 lines
672 B
C#
Raw Normal View History

2024-12-13 19:40:05 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class DisplayDayOfWeek : MonoBehaviour
{
public TextMeshProUGUI text;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// 获取当前日期
DateTime currentDate = DateTime.Now;
// 获取星期几(格式:星期一, 星期二...
string dayOfWeek = currentDate.ToString("dddd", System.Globalization.CultureInfo.GetCultureInfo("zh-CN"));
// 显示星期几
text.text =dayOfWeek;
}
}