Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Dates and Times in Python (2014) Let's Build a Timed Quiz App Timestamp Ordering

Andrei Oprescu
Andrei Oprescu
9,547 Points

I don't remember being taught this.

Hi! I have stumbled across a challenge that asked me this:

Create a function named timestamp_oldest that takes any number of POSIX timestamp arguments. Return the oldest one as a datetime object. Remember, POSIX timestamps are floats and lists have a .sort() method.

I don't remember a time where I was taught what a 'POSIX timestamp' is and I don't know how they are written.

can someone tell me what a 'POSIX timestamp' is?

Thanks!

Andrei

timestamp.py
# If you need help, look up datetime.datetime.fromtimestamp()
# Also, remember that you *will not* know how many timestamps
# are coming in.

1 Answer

A POSIX timestamp is also a unix epoch time https://www.epochconverter.com/

The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for 'Unix time'. Many Unix systems store epoch dates as a signed 32-bit integer, which might cause problems on January 19, 2038 (known as the Year 2038 problem or Y2038). The converter on this page converts timestamps in seconds, milliseconds and microseconds to readable dates.

TLDR: the number of seconds since midnight January 1970

Andrei Oprescu
Andrei Oprescu
9,547 Points

Hi again!

Just to be clear, a POSIX timestamp is any time from January 1 1970 midnight?

also, how do I accept more POSIX timestamps as it said that I don't know how many timestamps will come in?

Andrei

Yep, that's correct!

As for mmultiple arguments not 100% percent sure. might just be an array but will probaly be *args, have a look at this http://book.pythontips.com/en/latest/args_and_kwargs.html