All Questions
266 questions
0
votes
2
answers
55
views
ValueError: not enough values to unpack (expected 4, got 3), gps time to UTC
Trying to convert GPS times to a date and time of day in UTC. Inputs are space separated stream of x y seconds and output is a stream of x y z date time
This was designed to work with lidar data and ...
0
votes
3
answers
65
views
How can I parse a date time string with the 'WET' timezone
I am trying to parse a date string like this:
import datetime
document_updated_on = '01-Feb-2024#15:22 WET'
format_str = "%d-%b-%Y#%H:%M %Z"
updated_on_date = datetime.datetime.strptime(...
0
votes
2
answers
67
views
convert timestamp with offset to utc timestamp in python?
I have a dataframe with a column in it -
date_col
2024-05-12T17:46:50.746922-07:00
2024-05-12T17:31:35.438304-07:00
2024-05-12T17:46:50.642095-07:00
2024-05-12T17:02:02.299320-07:00
I tried below ...
0
votes
1
answer
159
views
Converting UTC Column into datetime in python pandas
I would like to ask for little support. I have here a python frame containing data giving in UTC format. I would like to transform the column into date-format.
Order Date
15-Feb-2024 UTC
17-Feb-2024 ...
1
vote
1
answer
241
views
get current UTC posix timestamp in better resolution than seconds in Python
I am trying to get a UTC posix timestamp in better resolution than seconds – milliseconds would be acceptable, but microseconds would be better. I need that as a synchronization for unrelated external ...
0
votes
2
answers
54
views
Reading UTC timestamp in python pandas and converting it to European dates
I have an issue with a timestamp column, hoping you can provide me some support. I checked here few already posted questions, but somehow I couldn't find the right approach from them.
I have a pandas ...
0
votes
1
answer
482
views
Python UTC America/New York Time Conversion
Working on a problem where I have to evaluate whether a time stamp (UTC) exceeds 7PM Americas/New_York.
I naively did my check as:
if (timestamp - timedelta(hours=4)).time() > 19:
__logic__
...
0
votes
0
answers
26
views
How to create cronjob such that reminders are triggered as per user timezone?
I have an app where I need to send reminders for upcoming sessions. Now, users are spread across the globe. There session timing is stored in UTC in the database. Now, I am getting confused as to how ...
0
votes
0
answers
89
views
How could I get hours of each timezone for 2000rows in dataframes
I used many methods to get what I want but it doesn’t work
I have dataframe for 2000rows and in this df, I have latitude and longitudes columns
I wants to get the hours for each rows in new column ...
-2
votes
1
answer
437
views
How to convert dates to UTC taking into account winter and summer time?
My objective is to convert a list of dates to the correct UTC format, i.e.: taking into consideration winter and summer time. Dates were scrapped from a chat.
I am Switzerland based which uses (CET) ...
0
votes
1
answer
694
views
Python Arrow datetime function returns a timestamp with seconds field value more than 60
I have a function in my code for taking a UTC time argument like - 2023-11-06T20:53:39.062Z, convert it to EST time and then return in a format as 'MM-DD-YYYY HH:MM:SS'.
def date_conv(time):
est = ...
2
votes
2
answers
107
views
utc time string convert to Unix timestamp, and then convert back to utc date time string. But the result is not matched with the original one
I expect 'utc' and 'utc_str_back' should be the same time, but result is diferent. Here is the code:
#input
utc='2023-09-20T05:04:54'
#calculation
utc_time = datetime.strptime(utc, '%Y-%m-%dT%H:%M:%S'...
0
votes
1
answer
94
views
Why does timezone unaware datetime object print out in local timezone?
When I instantiate a datetime object like this:
>>> print(datetime.datetime.now())
2023-09-16 10:30:15.50
I get the correct local time, which is currently around 10:30 AM.
Why is it like ...
0
votes
1
answer
129
views
datetime.utcfromtimestamp changing time in python
I have a string representing a datetime (ts). I want to transform it to int and then use
datetime.utcfromtimestamp to recover the same datetime:
ts = '2023-07-10 14:06:22.000 UTC'
int_ts = int(...
1
vote
1
answer
71
views
How to test whether timezone exists in Python/pandas?
I am working with pandas' tz_localize function to convert dates from local time to UTC:
time_zone = 'America/Santiago'
pd.to_datetime(pd.to_datetime(df['mydate']).apply(lambda x: datetime.strftime(...
1
vote
1
answer
184
views
Get UTC 'T' and 'Z' to show in DataFrame Column
Importing a dataframe in one datetime format, feeding into API service that requires dates in this UTC format (notice the T and Z):
2023-07-26T11:04:23.893Z
Noteworthy is this will be converted into ...
0
votes
1
answer
28
views
Failing to convert string do datetime pandas
I'm trying to perform de following operation:
pd.to_datetime('2023-05-02 11:52:09.000000 UTC', format='%Y-%m-%dT%H:%M:%S.%f')
But i'm getting the error: time data 2023-05-02 11:52:09.000000 UTC doesn'...
0
votes
2
answers
171
views
How to convert difference in hours to timezone in python?
I am currently working with apscheduler with multiple users located in different timezones.
There is no possibility to get the timezone from them automatically, so I need to do this with input data. ...
-3
votes
1
answer
47
views
convert utc date time to utc timestamp in Python
I need to convert date time to UTC timestamp. but the problem is; different systems returns different timestamps based on machine timezone.
example:
date1 = "2022-05-17 04:35:38"
UTC ...
0
votes
1
answer
137
views
How to change line to use local timezone (Europe/Ljubljana)? [duplicate]
I'm trying to change:
pytz.timezone('Europe/Ljubljana').localize(datetime.datetime.now().replace(microsecond=0))
to print time in Europe/Ljubljana but it still has offset of 2 hours (uses UTC and not ...
0
votes
0
answers
9
views
UTC Formatted string to datetime object [duplicate]
I have a dictionary of strings that are formatted in a UTC ISO 8601 manner.
Example:
"2022-11-05T22:36:48.701614+01:00"
I want to be able to convert these into seconds so that I can ...
0
votes
2
answers
54
views
UTC to Eastern Converter - Looping through list in a function
I have a csv of tweets with the column "created_at" that shows times in UTC as such:
Thu Mar 19 12:37:15 +0000 2015
I created this function so that is can convert a UTC time to Eastern time (...
0
votes
0
answers
28
views
Changing given observed data of a specific shape from UTC to LST in python
I have 3-hourly temperature data for 39 years. The shape of the data is data = (39,12,31,8) for 39 years, 12 months, 31 days, and 8 hours in UTC (which is 0000, 0300, 0600, 0900, 1200, 1500, 1800, and ...
-1
votes
1
answer
466
views
How to set Time zone to TIME_ZONE = "Asia/Karachi" in Django Project?
I want to change the timezone of my django project to Asia/Karachi. I have added this in my settings.py file:
TIME_ZONE = "Asia/Karachi"
Time zone of my postgres is also set to Asia/Karachi....
0
votes
1
answer
138
views
Which directive to use to parse Z in time string? [duplicate]
If I use fromisoformat (in Python3.11), then Z is parsed as UTC:
In [15]: dt.datetime.fromisoformat('2020-01-01T03:04:05Z')
Out[15]: datetime.datetime(2020, 1, 1, 3, 4, 5, tzinfo=datetime.timezone.utc)...
1
vote
1
answer
483
views
Convert String "YYYY-MM-DD hh:mm:ss Etc/GMT" to timestamp in UTC pandas
I have a pandas column of datetime-like string values like this exampe:
exammple_value = "2022-06-24 16:57:33 Etc/GMT"
Expected output
Timestamp('2022-06-24 16:57:33+0000', tz='UTC')
Etc/...
1
vote
1
answer
262
views
Is current time zone detected by default if `USE_TZ=True` in Django?
It is mentioned in docs that the current time zone should be activated.
You should set the current time zone to the end user’s actual time zone with activate(). Otherwise, the default time zone is ...
0
votes
1
answer
217
views
Converting Timestamp to UTC pandas [duplicate]
I have a pandas dataframe in the below format.
The Timestamp values are in DateTime format (GMT Time)
I want to add a new column to the dataframe with the UTC values related to each Timestamp.
How can ...
0
votes
1
answer
270
views
pytz.timezone error converting because of change in when chile change the hour
I am using the pytz python library.
It usually converts well from "America/Santiago" to "UTC.
The problem is that usually chile change its hour on the first saturday of september but ...
1
vote
3
answers
1k
views
Unix timestamp conversion to time with microsecond accuracy of seconds
I have 1000 of UYC timestamps in csv file, I want to convert it into date and time but I am only interested in second like
Timestamps= 1666181576.26295,
1666181609.54292
19/10/2022 15:45:25.34568
...
1
vote
0
answers
117
views
time[ISO-UTC] to datetime pandas dataframe
How can I convert the following UTC Time string to datetime in pandas dataframe?
ex. "20200114T085957600"
I tried:
df["Time"]=pd.to_datetime(df['time[ISO-UTC]']).dt.strftime('%Y%m%...
0
votes
3
answers
955
views
Why do i keep getting UTC time zone even when Django settings is configured differently
I'm not sure why the datetime response is always one hour behind (UTC)
Django settings configuration
LANGUAGE_CODE = "en-us"
TIME_ZONE = "Africa/Lagos"
USE_I18N = True
USE_L10N = ...
-1
votes
1
answer
262
views
converting time given from user input to utc
I want to convert a time given from user to UTC/RFC 3339 format.
For example, if they gave the string 2022-07-20 1:09:51 I want it to print it 2022-07-20T20:08:51Z. I got how to do it if given the ...
0
votes
2
answers
731
views
How to plot local date and time vs temperature from CSV file that uses UTC for date and time
I have a CSV file where each row has date and time and temperature, where the date and time are UTC.
I can plot temperature as a function of time, but the X axis shows the UTC time.
What is the best ...
2
votes
0
answers
8k
views
Convert Date time to UTC Time in python [duplicate]
I have datetime value in format of 2022-01-26T07:01:36-08:00 (based on which user fetches data, it will have local timezone, like -08:00, +05:30)
I want to convert this time into UTC Time.
I saw ...
0
votes
1
answer
519
views
Python - How can I check if a UTC date string is correct?
I receive a date value on a POST request, and it has this format 20220509T000000Z.
In the system where I am working on, sometimes users can send wrong date values like 2022059T000000Z and ...
2
votes
0
answers
131
views
Converting text to datetime.datetime object? (Error: ValueError: time data '2022-04-18T10:00:00-07:00' does not match format '%y-%m-%dT%H:%M:%S%z')
I have a datetime.datetime object that gets stored as text in a text file. Later, I have to convert that text back to a datetime.datetime object. The object is in this format 2022-04-18T10:00:00-07:00 ...
3
votes
1
answer
3k
views
Python datetime utcnow does not set timezone?
Found this issues working with timestamp conversions where the .timestamp() seem to compensate for time offset even though I created the datetime object with utcnow() method. So what is the reason for ...
0
votes
0
answers
321
views
Get global UTC timestamp across all platforms
I am trying to get the current timestamp for my program on both the client side, and the server side in python. However, my friends, along with myself, have problems. I have tried syncing both times, ...
0
votes
1
answer
474
views
How to convert a Pandas Timestamp to UTC seconds as an int?
I tried to convert it over like this but it still doesn't work as intended.
ts = pd.Timestamp('2022-01-02T12')
ts_utc = ts.replace(tzinfo=timezone.utc)
x = pd.Timestamp.utcnow()
ts_delta = x - ts_utc
...
0
votes
2
answers
1k
views
How to convert timezone in number to UTC?
I have some random dates with different timezones, they are in formats like this "07 Mar 2022 13:52:00 -0300", or they could be like this: "07 Mar 2022 11:12:00 -0700". I don't ...
0
votes
2
answers
3k
views
python pandas converting UTC integer to datetime
I am calling some financial data from an API which is storing the time values as (I think) UTC (example below):
enter image description here
I cannot seem to convert the entire column into a useable ...
0
votes
1
answer
101
views
how to create a certain pandas data type (date and time with timezone)
I want to use datetime.datetime.now() to create the time in the following format to match the output from an API: 2022-02-25T18:05:00+00:00.
When I use dtypes on the API output it says datetime64[ns, ...
0
votes
1
answer
763
views
Get GPS to UTC leap seconds
Is there a simple way to get leap seconds between gps and utc time through an API or python library which is automatically update if the leap seconds change over the years ?
28
votes
8
answers
37k
views
ZoneInfoNotFoundError: 'No time zone found with key utc'
While trying to load my webpage on the browser, I got the message.
A server error occurred. Please contact the administrator
And when I go back to check my termimal, I see the message
zoneinfo....
0
votes
1
answer
594
views
How to get timezone from iso time string in Python?
For instance this:
my_timestamp = '2022-01-02T02:00:02-08:00'
We know that +00:00 is considered UTC, this timestamp -08:00 indicates America/Los_Angeles.
Is there any way to explicitly get that ...
1
vote
0
answers
603
views
How to run a function at a certain UTC time?
I'm writing a small script that starts a function at a certain time (16:00 for example), the problem is that my script obviously works based on the time of the computer, but I need it to use UTC, so ...
0
votes
1
answer
120
views
Delete django data without RuntimeWarning: DateTimeField received a naive datetime
I am trying to delete 3 years old data in my python django db. Here is code:
from datetime import datetime
from dateutil.relativedelta import relativedelta
def db_cleanup():
cleanup_start = ...
-1
votes
1
answer
2k
views
Converting GPS time to UTC
As a part of my Master's project I collect data with an RTK receiver and for matching some x,y,z,time data with scientific measurements I need to convert some GPS time ( GPS Week & Milliseconds ...
0
votes
0
answers
2k
views
String type timestamp to datetime conversion in Python with timezone
I want to convert a timestamp in a string format which I get out of a pandas dataframe to a timestamp in datetime format in order to be able to compare it to another timestamp (also in string format) ...