ERROR ? daily-coding-challenge/2026-01-27

Hi I tried solve this challenge, but one test case seems to be not ok,
or maybe I do not understand correctly the context.

  1. odd_or_even_day(86400000) should return “even”.

but I checked and in my location this is
python: print(time.gmtime(86400000)) = 1972-09-27 00:00:00
python: print(datetime.utcfromtimestamp(86400000)) = 1972-09-27 00:00:00

I did additional test:
print(datetime.utcfromtimestamp(timestamp))
1972-09-27 00:00:00
print(datetime.fromtimestamp(timestamp, tz=timezone.utc))
1972-09-27 00:00:00+00:00
print(datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp))
1972-09-27 00:00:00+00:00

then 27 day is odd number, should I use different timezones ?

you should probably use UTC

can you share a link to the challenge?

Yes, from my recollection, it’s necessary to use UTC for all challenges which involve manipulating date objects.

I have prepared some test:

https://www.freecodecamp.org/learn/daily-coding-challenge/2026-01-27#:~:text=JavaScript-,Python,-Console

I think this is the test issue, e.g:

python: print(datetime.fromtimestamp(86400000, tz=None))
return: 1972-09-27 01:00:00
this is my local time UTC+1

python: print(datetime.fromtimestamp(86400000, tz=timezone.utc))
return: 1972-09-27 00:00:00+00:00
this is the UTC time

and as you can check by hand this is 27 day not 26 :slight_smile:
I think the test is correct for timezones UTC - *

can you provide the code you are using so we can test also?

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

from datetime import datetime
from datetime import timezone
from datetime import timedelta
from datetime import tzinfo


def odd_or_even_day(timestamp):

    date_in_utc = datetime.fromtimestamp(timestamp, tz=timezone.utc)
    print(date_in_utc.day)
    print(date_in_utc.tzinfo)
    print(date_in_utc)

    date_in_local = datetime.fromtimestamp(timestamp)    
    print(date_in_local.day)
    print(date_in_local.tzinfo)
    print(date_in_local)
        
    # print(datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp))
    # if day % 2 == 0:
    #     return 'even'
    # else:
    #     return 'odd'

print(odd_or_even_day(86400000))

output for UTC:
27
UTC
1972-09-27 00:00:00+00:00

output for New Heaven USA time-zone (changed on my local computer):
26
None
1972-09-26 20:00:00

I am trying your code but I get ValueError: year 58042 is out of range

yes, i know, please look into code from comment :slight_smile:

if you think this is a bug, please open a github issue about this, or comment on this existing issue Challenge 170: Odd or Even Day Test 3 issue · Issue #65521 · freeCodeCamp/freeCodeCamp · GitHub

1 Like

In Python, you need to convert the timestamp from milliseconds to seconds before applying fromtimestamp. You are not doing that.

1 Like

Yes,
may bad, thanks for the info :slight_smile: