TimeManager.cs 694 B

12345678910111213141516171819202122
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class TimeManager : UpdateManager
  7. {
  8. public Text timetext;
  9. public string gxlj= "HH:mm:ss";
  10. public override void updateData()
  11. {
  12. base.updateData();
  13. DateTime now = DateTime.Now; // 获取当前本地时间
  14. string dateString = now.ToString("yyyy-MM-dd"); // 格式化日期部分
  15. string timeString = now.ToString(gxlj); // 格式化时间部分
  16. string dateTimeString = dateString + " " + timeString;
  17. // Debug.Log("dateTimeString==>" + dateTimeString);
  18. timetext.text = dateTimeString.ToString();
  19. }
  20. }