Managing time properly.

I’m trying to write a script that will set and manage time.

I’ve been working on this on and off for a few weeks in my spare time, I don’t normally have to ask for help, so I apologize in advanced if I’m not clear enough to begin with.

I’m hoping to keep the script simple, as i plan to have other scripts referencing and or waiting on time values (hours/days/months/years).

id like the script to work in real time where 1 second is 1 second and upto and beyond 1 second = 1 day.

I’ve played around with updates and enumerates with waitforsecconds but all i’ve gotten is more confused and a headache.

I don’t know enough about unity to know if i should have something like this updating every frame and how hard it will hurt performance.

Any help would be gladly appreciated.
Regards, Nick.

EDIT: I want to have a variable or other value that will tell me what the time is. on top of that i need a way to pause, speed up and set a new time & date.
I need a value that keeps the time, in real time 1 second is 1 second. but i want to speed it up and slow/pause it.

I want to have other values that are time dependant, so X per day or Y per year.

Get the current date/time with DateTime.Now.

Pause, slow down, and speed up time by adjusting Time.timeScale.

Assuming you’re on Windows, you can set a new system time and date using a p/invoke to SetSystemTime. Not quite sure why you’d want to do this though…