|
| 21 Dec 2012 02:52 PM |
I can't figure it out. I have the rest of the algorithm (below) but hours aren't working right.
local secondsPassed = os ~= nil and os.time() or tick() local year = 1970 + math.floor(secondsPassed / (86400 * 365.25)) local days = math.floor((secondsPassed % (365.25 * 86400)) / 86400) days = days + (year - 2011) -- BROKEN -- 86400 = 1 day (60*60*24) local hours = math.floor((secondsPassed % 86400) / 3600)
local minutes = math.floor((secondsPassed % 3600) / 60) local seconds = math.floor(secondsPassed % 60) |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:01 PM |
days_now = math.floor(tick() / (60 * 60 * 24)) years_now = math.floor(days_now / 365.25) months_now = years_now * 12 hours_now = days_now * 24 minutes_now = hours_now / 60 seconds_now = math.floor(tick())
|
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:05 PM |
That doesn't work
print(hours_now) --> 376680 |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:06 PM |
Yes, that prints the hours since January 1st 1970...
- thedestroyer115 |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:07 PM |
| Not the current hour, though. How would i get that? |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:09 PM |
| You wanted the current hour? |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Dec 2012 03:11 PM |
print(hour_now / days_now)
Maybe? |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Dec 2012 03:23 PM |
hours_now = math.floor(tick() / (60 * 60)) days_now = math.ceil(tick() / (60 * 60 * 24)) d = days_now * 24 print(d - hours_now)
Here you go. |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:23 PM |
Returns the time in UNIX time, which is the number of seconds since the Unix epoch, January 1st, 1970. This time advances without game running, network synchronization, or wait(). Using tick() in a LocalScript may result in a different number that if you were to use it in a Script because using it in a LocalScript will fetch the user's current time while using it in a Script will fetch the server's current time. tick() is very accurate. Because of its high accuracy, it can be used to measure the time a certain function takes to execute by calling it before and after an operation has been done, then finding the difference.
Using tick() in a LocalScript may result in a different number that if you were to use it in a Script because using it in a LocalScript will fetch the user's current time while using it in a Script will fetch the server's current time.
LocalScript will fetch the user's current time |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:24 PM |
Or do some maths like I did.
- thedestroyer115 |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:43 PM |
Destroyer: That still doesn't work. The output is '3' when it should be '12'
|
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:45 PM |
Different time zones man.
- thedestroyer115 |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:47 PM |
| How is that time-zone dependant? I'm using os.time instead of tick so it should be local time, which shouldn't need time zones. |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2012 03:59 PM |
| If you want to get the player's local time, place tick() in a LocalScript, then place it in the player, the player's character, tool, gui, something player-oriented |
|
|
| Report Abuse |
|
|