utc

How to convert C++ chrono time in UTC to string in UTC

回眸只為那壹抹淺笑 提交于 2021-01-29 04:46:59
问题 How to convert C++ chrono time in UTC to string in UTC? Because in my tests when convert chrono time to string it is using different timezone. Example: #include <iostream> #include <string> #include <chrono> #include <sstream> #include <iomanip> #include <cstdint> #include <ctime> std::string getStringFromDateTime(const std::chrono::system_clock::time_point & value) { std::time_t time_now_t = std::chrono::system_clock::to_time_t(value); std::tm now_tm = *std::localtime(&time_now_t); char buf

Convert pandas dataframe column of UTC time string to floats

瘦欲@ 提交于 2021-01-28 10:38:11
问题 I have a pandas dataframe with a column of strings, with datetimes in UTC format, but need to convert them to floats. I'm having trouble doing this. Here is a view of my column: df['time'][0:3] 0 2018-04-18T19:00:00.000000000Z 1 2018-04-18T19:15:00.000000000Z 2 2018-04-18T19:30:00.000000000Z Name: time, dtype: object I've been trying this, but isn't working for me: import datetime for i in range(1,len(df)): df['time'][i] = datetime.datetime.strptime(df['time'][i], '%Y-%m-%dT%H:%M:%S.%f000Z')

Android Kotlin / JAVA - get current world time / UTC in seconds since 1970

北战南征 提交于 2021-01-28 03:15:52
问题 As the title says I need the current workd time in seconds since 1970. This is what I've tried so far: System.currentTimeMillis() and val df = DateFormat.getTimeInstance() df.setTimeZone(TimeZone.getTimeZone("gmt")) val gmtTime = df.format(Date()) But both are showing the time which is based on the phone time, so when a user changes the phone time manually it will be affected Is there a way to get the current workd time in seconds without using an extern API? 回答1: No, the only way to get time

How to get UTC Date object in NodeJS? [duplicate]

时光毁灭记忆、已成空白 提交于 2021-01-21 06:33:42
问题 This question already has answers here : How do you convert a JavaScript date to UTC? (29 answers) Closed 2 years ago . I want to get the Current Date object in UTC and then store it using Mongoose. I tried using new Date() , Date.now() etc. But all these returns local time. How do I get the UTC date object? I want the Date object, not string representation. 回答1: Just use new Date(new Date().toUTCString()) After converting to UTC, we have to again convert it into Date object if we need a Date

Convert LocalDateTime to LocalDateTime in UTC

狂风中的少年 提交于 2021-01-20 14:17:38
问题 Convert LocalDateTime to LocalDateTime in UTC. LocalDateTime convertToUtc(LocalDateTime date) { //do conversion } I searched over net. But did not get a solution 回答1: I personally prefer LocalDateTime.now(ZoneOffset.UTC); as it is the most readable option. 回答2: There is an even simpler way LocalDateTime.now(Clock.systemUTC()) 回答3: LocalDateTime does not contain Zone information. ZonedDatetime does. If you want to convert LocalDateTime to UTC, you need to wrap by ZonedDateTime fist. You can

Convert LocalDateTime to LocalDateTime in UTC

你。 提交于 2021-01-20 14:16:09
问题 Convert LocalDateTime to LocalDateTime in UTC. LocalDateTime convertToUtc(LocalDateTime date) { //do conversion } I searched over net. But did not get a solution 回答1: I personally prefer LocalDateTime.now(ZoneOffset.UTC); as it is the most readable option. 回答2: There is an even simpler way LocalDateTime.now(Clock.systemUTC()) 回答3: LocalDateTime does not contain Zone information. ZonedDatetime does. If you want to convert LocalDateTime to UTC, you need to wrap by ZonedDateTime fist. You can

Python Datetime : use strftime() with a timezone-aware date

笑着哭i 提交于 2020-12-28 13:19:22
问题 Suppose I have date d like this : >>> d datetime(2009, 4, 19, 21, 12, tzinfo=tzoffset(None, -7200)) As you can see, it is "timezone aware", there is an offset of 2 Hour, utctime is >>> d.utctimetuple() time.struct_time(tm_year=2009, tm_mon=4, tm_mday=19, tm_hour=23, tm_min=12, tm_sec=0, tm_wday=6, tm_yday=109, tm_isdst=0) So, real UTC date is 19th March 2009 23 :12:00, right ? Now I need to format my date in string, I use >>> d.strftime('%Y-%m-%d %H:%M:%S.%f') '2009-04-19 21:12:00.000000'

Python Datetime : use strftime() with a timezone-aware date

允我心安 提交于 2020-12-28 13:18:42
问题 Suppose I have date d like this : >>> d datetime(2009, 4, 19, 21, 12, tzinfo=tzoffset(None, -7200)) As you can see, it is "timezone aware", there is an offset of 2 Hour, utctime is >>> d.utctimetuple() time.struct_time(tm_year=2009, tm_mon=4, tm_mday=19, tm_hour=23, tm_min=12, tm_sec=0, tm_wday=6, tm_yday=109, tm_isdst=0) So, real UTC date is 19th March 2009 23 :12:00, right ? Now I need to format my date in string, I use >>> d.strftime('%Y-%m-%d %H:%M:%S.%f') '2009-04-19 21:12:00.000000'

Python Datetime : use strftime() with a timezone-aware date

北城以北 提交于 2020-12-28 13:13:15
问题 Suppose I have date d like this : >>> d datetime(2009, 4, 19, 21, 12, tzinfo=tzoffset(None, -7200)) As you can see, it is "timezone aware", there is an offset of 2 Hour, utctime is >>> d.utctimetuple() time.struct_time(tm_year=2009, tm_mon=4, tm_mday=19, tm_hour=23, tm_min=12, tm_sec=0, tm_wday=6, tm_yday=109, tm_isdst=0) So, real UTC date is 19th March 2009 23 :12:00, right ? Now I need to format my date in string, I use >>> d.strftime('%Y-%m-%d %H:%M:%S.%f') '2009-04-19 21:12:00.000000'

Python Datetime : use strftime() with a timezone-aware date

烈酒焚心 提交于 2020-12-28 13:12:49
问题 Suppose I have date d like this : >>> d datetime(2009, 4, 19, 21, 12, tzinfo=tzoffset(None, -7200)) As you can see, it is "timezone aware", there is an offset of 2 Hour, utctime is >>> d.utctimetuple() time.struct_time(tm_year=2009, tm_mon=4, tm_mday=19, tm_hour=23, tm_min=12, tm_sec=0, tm_wday=6, tm_yday=109, tm_isdst=0) So, real UTC date is 19th March 2009 23 :12:00, right ? Now I need to format my date in string, I use >>> d.strftime('%Y-%m-%d %H:%M:%S.%f') '2009-04-19 21:12:00.000000'