BLACKISH DEV BLOG Support
 

 

Unity: Dates

An example of how to deal with dates (more info here):

var day1 = new System.DateTime(2010, 3, 12); // Year, Month, Day
var day2 = System.DateTime.Today;
var timeframe = System.TimeSpan(8,0,0,0); //Days, Hours, Minutes, Seconds

print(day1); //output: 03/12/2010 00:00:00
print(day2); //output: 03/17/2010 00:00:00

print(day2 - day1 + " < " + timeframe + " ?"); //output: 5.00:00:00 < 8.00:00:00 ?

if(day2 - day1 < timeframe) {
print("Within time period");
} else {
print("Time period exceeded");
}
Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>