Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TimeDemo : MonoBehaviour
- {
- string[] monthsList = { "січ", "лют", "бер", "кві", "тра", "чер", "лип", "сер", "вер", "жов", "лис", "гру" };
- public int years; // рік
- public int months = 1; // місяць
- public int days = 1; // день
- public int hours; // час
- public int minutes; // хвилина
- public int seconds; // секунда
- float counter; // лічильник
- void FixedUpdate()
- {
- counter += Time.fixedDeltaTime;
- if (counter >= 1f) {
- seconds++;
- counter = 0;
- if (seconds > 59) {
- seconds = 0;
- minutes++;
- if (minutes > 59) {
- minutes = 0;
- hours++;
- if (hours > 23) {
- hours = 0;
- days++;
- if (days > 30) {
- days = 1;
- months++;
- if (months > 12) {
- months = 1;
- years++;
- }
- }
- }
- }
- }
- string sec = (seconds < 10 ? "0" : "") + seconds.ToString();
- string min = (minutes < 10 ? "0" : "") + minutes.ToString();
- string hr = (hours < 10 ? "0" : "") + hours.ToString();
- string dd = (days < 10 ? "0" : "") + days.ToString();
- string mm = monthsList[months - 1];
- string yy = years.ToString();
- Debug.Log(hr + ":" + min + ":" + sec + " " + dd + " " + mm + " " + yy);
- }
- }
- }
Add Comment
Please, Sign In to add comment