Hi there, iam a freshman in using UNITY3D and i need for a project to read out the system time and date of the computer my game is running on. is there any way in java, c, or boo to do this?
lots of thanks ThisIsTom
Hi there, iam a freshman in using UNITY3D and i need for a project to read out the system time and date of the computer my game is running on. is there any way in java, c, or boo to do this?
lots of thanks ThisIsTom
Yes, you have access to most of the .net classes including the System.DateTime structure, and more specifically you can get the current date and time using the DateTime.now property.
Ah yes, "DateTime" is part of .Net's System class which isn't included by default. You can fix this two ways: either change it to System.DateTime.now everywhere you use it, or add using System; at the top of your c# script (or in JS, add import System; at the top). Duck 1 min ago
– ducki just tried out that System.DateTime.now and unity said 'now' is not a mamber of Date; did you mean: 'Now' so the real version of the JS is var systemTime = System.DateTime.Now;
– anon98399972This may help. Try using variables like these and see how it goes. You do have to
theTime = System.DateTime.Now.ToString("hh:mm:ss"); theDate = System.DateTime.Now.ToString("MM/dd/yyyy"); theMonth = System.DateTime.Now.get_Month(); theDay = System.DateTime.Now.get_Day();
I try to do it, but I don't see saved data PlayerPrefs.SetString("date time" System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); Debug.Log(PlayerPrefs.GetString("date time")); Here what it show: UnityEngine.Debug:Log(Object)
– AmazingDeveloper2@dmitry-kozyr try this
PlayerPrefs.SetString(“date_time”, System.DateTime.Now.ToString(“yyyy/MM/dd HH:mm:ss”));
Debug.Log(PlayerPrefs.GetString(“date_time”));
Have any of you tried it in developement build? Because I just realized, that from the build I get the date and time of the creation, not the current. Anyone knows why it could happen? It's not the code, I'm shure, but had anyone ever had it, and know what caused it?
– fzksbalint