1

I've a program that divides the datetime in minutes - hours. It works well in Windows but trying it on server or WSL, it didn't work

    filter_by = pd.Timestamp("today").floor("H") - pd.offsets.Minute(
        int(time)
    )

Same code running in WSL, I get

2021-11-17T17:45:00.000000000 

While running in Windows, I get the correct time

2021-11-17T23:30:00.000000000

I've changed the Ubuntu time settings as well to Asia/Kolkata, Windows is on Asia/Kolkata still it didn't work.

Any suggestions?

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
Kavi Harjani
  • 661
  • 5
  • 15
  • I suspect different time zone settings on Windows and WSL (not sure if the settings you changed actually have an effect on what Python/pandas uses). Try `pd.Timestamp('today', tz='UTC')` and you should get results that agree. – FObersteiner Nov 17 '21 at 20:08
  • Hey @MrFuppes thanks, but even that didn't work – Kavi Harjani Nov 18 '21 at 02:51
  • Does this answer your question? [WSL2 Clock is out of sync with Windows](https://stackoverflow.com/questions/65086856/wsl2-clock-is-out-of-sync-with-windows) – sound wave Feb 24 '23 at 14:22

1 Answers1

0

After trying all of the solutions i could find,

changing the time offset to python is what worked for me

    tz_IN = pytz.timezone("Asia/Kolkata")
    datetime_IN = datetime.datetime.now(tz_IN) - datetime.timedelta(
        minutes=int(time)
    )
Kavi Harjani
  • 661
  • 5
  • 15
  • What is variable `time`? – FObersteiner Nov 18 '21 at 05:45
  • @MrFuppes that's a number input given by the user You can try it live here [link](https://Kaviharjani.com) The 15-30-45 time bifurcation is time variable – Kavi Harjani Nov 18 '21 at 16:39
  • 1
    if this is just an offset, I don't think it is relevant for the question, no? Also, `pd.Timestamp("today").floor("H")` and `datetime.datetime.now(tz_IN)` are different in that the first is floored to the hour while the second is not. – FObersteiner Nov 19 '21 at 07:59
  • @MrFuppes thanks for the suggestion i switched to python and worked as I didn't want to spend more time, and if someone is stuck on similar problem could switch if needed a quick solution but still I wonder why was the `pd.Timestamp("today").floor("H")` working in windows OS but not ubuntu, however, +1 for replying :) – Kavi Harjani Nov 21 '21 at 16:06