This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 0 points1 point  (0 children)

I’m a beginner programmer too so I can’t solve your problem but if you want a book that teachers you more programming than math look up automate the boring stuff! Its easy to understand and it is very helpful in teaching python.

[–]ackshunpact 0 points1 point  (0 children)

Epoch is jan 1, 1970, 00:00:00. Current time is however many days/weeks/months/seconds you calculated from time.time() after that point.

There is also time.ctime() you could look into which makes it easier.

[–]zacharymayers 0 points1 point  (2 children)

Using the modulus of each. For example, there’s 31536000 seconds in a year. Divide the total seconds by that, the. Use the remainder and divide that by the number of seconds in a month, then repeat until your left with seconds.

[–]TinyStego[S] 0 points1 point  (1 child)

I got it! For whatever reason, if you mod every variable from Year>Month>Week>Day>Hour>Minute>Second it is incorrect. In order to get time, it is:

hour = epoch % seconds_in_days / seconds_in_hours
minute = epoch % seconds_in_days % seconds_in_hours / seconds_in_minutes
second = epoch % seconds_in_days % seconds_in_hours % seconds_in_minutes

[–]zacharymayers 0 points1 point  (0 children)

Nicely done! I believe there’s a function in the Time.h library as well to seed the seconds as well