Unity&c# Time Related

Source: Internet
Author: User
Tags add time current time local time string format
1.Unity Time Class

1/ Time.time said that from the game development to the present time, will be suspended with the game to stop the calculation.

2/ Time.timesincelevelload indicates that the time from the current scene start to date will also stop with the pause operation.

3/ Time.deltatime represents the current frame time from the previous frame, in seconds.

Timer through this use, update to add Time.deltatime, is the elapsed time

4/ Time.fixedtime represents the time at which the game starts in seconds, and the fixed time is updated at regular intervals (equivalent to fixeddeltatime) until the timing property is reached.

5/ Time.fixeddeltatime indicates that the Edit->projectsettings->time fixed timestep can be set automatically at the interval of a second, with updates at the physical and other fixing frame rates.

6/ Time.smoothdeltatime represents a smooth deltatime, according to the former
The value of the time weighted average of n frames.

7/ Time.timescale time scaling, the default value is 1, if set <1, indicating time slows down, if set >1, indicating time to speed up, can be used to speed up and deceleration game, very useful.

8/ Total frame number of Time.framecount

9/ Time.realtimesincestartup that the total time since the start of the game, even if the pause will continue to increase.

The 10/ time.captureframerate indicates that the frame rate per second is set, and then the real time is not considered.

11/ Time.unscaleddeltatime does not consider the timescale time and deltatime the same, if the timescale is set, it is invalid.

12/ Time.unscaledtime does not consider the timescale time is the same, if the timescale is set, it is invalid.

from:http://blog.csdn.net/liuyang_sy/article/details/46811125 2.c#-system.datetime

Date-Time related processing:

0/constructor: DateTime (Int32, Int32, Int32) datetime (year, month, day, time, minute, second, (can be added in milliseconds)/Coordinated Universal Time (UTC) or local time) ...
1/attribute: DateTime dt = DateTime.Now; Dt. ToString ();//1/22/2017 3:43:19 PM//Gets a DateTime object that is set to the current date and time on this computer, expressed as local time.

[Affected by time zone; we use East eight in China, so we have 8 hours with UTC]
DateTime DT2 = Datetime.today; DT2.

ToString ();//1/22/2017 12:00:00am Day date, and its time component is set to 00:00:00.
DateTime DT3 = Datetime.utcnow; DT3. ToString ();//1/22/2017 7:43:19 AM The current date and time on this computer, expressed as Coordinated Universal Time (utc,0 time zone) dt. Year.tostring ();//2017 dt.

Date.tostring ();//1/22/2017 12:00:00 am Gets the date portion of this instance, the date is the same as this instance, and the time value is set to 12:00:00 midnight (00:00:00). Dt. Day.tostring ();

22 get the date represented by this instance is the day ordinal of the month. Dt.

Dayofweek.tostring ();//sunday gets the day of the week that this instance represents. Dt.

Dayofyear.tostring ();//22 gets the date represented by this instance is the day ordinal of the year. Dt. Hour.tostring ();//14 gets the hour portion of the date represented by this instance. 24h (System) dt.

Kind.tostring ();//local returns local time, Coordinated Universal Time (UTC), or both dt.Millisecond.ToString ();//630 gets the millisecond portion of the date represented by this instance. Dt. Minute.tostring ();//35 gets the minute portion of the date represented by this instance dt. Month.tostring ();//1 gets the month portion of the date represented by this instance dt. Second.tostring ();//28 get this realThe second part of the date represented by the example dt.
Ticks.tostring ();//632667942284412864 gets the number of ticks that represent the date and time of this instance. Each tick represents 100 nanoseconds, or one out of 10,000 seconds. There are 10,000 ticks in 1 milliseconds. The value of this property represents the number of intervals that have elapsed in 100 nanoseconds since 12:00:00 midnight January 1, 01 (representing Datetime.minvalue).

It does not include the number of ticks that are attributed to leap seconds. Dt.
Timeofday.tostring ();//15:20:43.1911987 the time of day on which this instance was obtained. ----------2/method: dt. Tofiletime ().

ToString ();//131295394816200492 converts the value of the current DateTime object to the Windows file time. Dt. TOFILETIMEUTC (). ToString ();//131295683210873066 converts the value of the current DateTime object to the Windows file time dt. ToLocalTime (). ToString ();//1/22/2017 2:19:17 PM Converts the value of the current DateTime object to local time dt. Tolongdatestring (). ToString ();//sunday,january 22,2017 to a long date string representation dt. Tolongtimestring ().

ToString ();//2:20:33 pm to its equivalent long time string representation. Dt. ToOADate (). ToString ();//42757.5978641782 converted to the equivalent OLE Automation date dt. ToShortDateString (). ToString ();//1/22/2017 dt. Toshorttimestring (). ToString ();//2:21 PM dt. ToUniversalTime (). ToString ();//1/22/2017 6:22:10am converted to Coordinated Universal Time (UTC dt. Addyears (1). ToString ();//1/22/2018 3:51:20 pm Increase/Decrease Year (parameter can be negative) dt. AddDays (1.1). ToString ();//1/23/2017 6:16:36 PM dt. ADdhours (1.1). ToString ();//2005-11-5 14:53:04 dt. Addmilliseconds (1.1). ToString ();//2005-11-5 13:47:04 dt. Addmonths (1). ToString ();//2005-12-5 13:47:04 dt. AddSeconds (1.1). ToString ();//2005-11-5 13:47:05 dt. AddMinutes (1.1). ToString ();//2005-11-5 13:48:10 dt. Addticks (1000). ToString ();//2005-11-5 13:47:04 the number of ticks Dt.compareto (DT). ToString ();//2 time comparison: Earlier than <0, meanwhile ==0, later than >0[static&&not static] dt. ADD (?). ToString ()//question mark is a time period TimeSpan dt. Equals ("2005-11-6 16:11:04"). ToString ();//false [Static&&not static] Returns whether it has the same date and time dt. Equals (DT). ToString ();//true dt. GetHashCode (). ToString ();//1474088234 dt. GetType (). ToString ();//system.datetime dt. GetTypeCode (). ToString ();//datetime dt. Getdatetimeformats (' s ') [0]. ToString ();//2005-11-05t14:06:25 dt. Getdatetimeformats (' t ') [0]. ToString ();//14:06 dt. Getdatetimeformats (' y ') [0]. ToString ();//November 2005 dt. Getdatetimeformats (' D ') [0]. ToString ();//November 5, 2005 dt. Getdatetimeformats (' D ') [1]. ToString ();//2005 dt. Getdatetimeformats (' D ') [2]. ToStRing ();//week 62,005 dt. Getdatetimeformats (' D ') [3]. ToString ()//Saturday November 5, 2005 dt. Getdatetimeformats (' M ') [0]. ToString ();//November 5 dt. Getdatetimeformats (' f ') [0]. ToString ();//November 5, 2005 14:06 dt. Getdatetimeformats (' g ') [0]. ToString ();//2005-11-5 14:06 dt. Getdatetimeformats (' R ') [0]. ToString ();//sat, Nov 14:06:25 GMT Note: string format string: String. Format ("{0:d}", dt);//2005-11-5 string. Format ("{0:d}", dt);//November 5, 2005 string. Format ("{0:f}", dt);//November 5, 2005 14:23 string. Format ("{0:f}", dt);//November 5, 2005 14:23:23 string. Format ("{0:g}", DT);//2005-11-5 14:23 string. Format ("{0:g}", DT);//2005-11-5 14:23:23 string. Format ("{0:m}", dt);//November 5 string. Format ("{0:r}", DT);//sat, Nov 14:23:23 GMT string. Format ("{0:s}", dt);//2005-11-05t14:23:23 string. Format ("{0:t}", dt);//14:23 string. Format ("{0:t}", dt);//14:23:23 string. Format ("{0:u}", DT);//2005-11-05 14:23:23z string. Format ("{0:u}", dt);//November 5, 2005 6:23:23 string. Format ("{0:y}", dt);//November 2005 string. Format ("{0}", dt);//2005-11-5 14:23:23 StrinG.format ("{0:yyyymmddhhmmssffff}", DT);//201701221603353262//datetime.now.tostring (IFormatProvider Provider) Usage:/ /Note: HH for the 24-hour HH for the 12-hour system, month-day time seconds yyyy mm DD HH mm SS//datetime.now.tostring ("yyyy mm month DD day"); YYYY year mm month DD Day//datetime.now.tostring ("hh:mm");
19:48-----------------------------------------------calculates the number of days of the month of the year int = Datetime.daysinmonth (2007, 8);
days = 31;
-----------------------------------------------add a day to the date, reduce the day DateTime DT =datetime.now; Dt. AddDays (1); Increase one day dt. AddDays (-1);//reduce one day other year method similar ...
3. Time Stamp

A timestamp (timestamp), usually a sequence of characters, that uniquely identifies a moment of time.
Time stamp refers to the GMT January 01, 1970 00:00 00 seconds (Beijing time January 01, 1970 08:00 00 seconds) up to now the total number of milliseconds.

1/c# generates a timestamp: (here in seconds)

private static string Gettimestamp ()
{
    TimeSpan ts = datetime.utcnow-new DateTime (1970, 1, 1, 0, 0, 0, 0);  
    Return Convert.toint64 (TS. totalseconds). ToString ();  
}

2/c# timestamp converted to format time: (here in seconds)

Private datetime GetTime (string timeStamp)  
{  
  DateTime Dtstart = TimeZone.CurrentTimeZone.ToLocalTime (new DateTime (1970, 1, 1));  The timestamp start point reverts to the current time zone
  long ltime = long. Parse (TimeStamp + "0000000");//Convert to Long type  
  TimeSpan tonow = new TimeSpan (ltime);//time interval return
  Dtstart.add ( Tonow); Plus time interval to get target time
}  

from:http://blog.csdn.net/fengqingtao2008/article/details/45271915
Preparation: Lua timestamp related, see another article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.