Questions tagged [localtime]

Calendar time expressed relative to the user's local timezone.

Calendar time expressed relative to the user's local timezone.

461 questions
4
votes
2 answers

java: summing LocalTimes difference

I have multiple working hours in LocalTime and I want to check if the time exceeds 24 hours. The time is in 24h format. For example: 02:00 - 08:00 10:00 - 12:00 23:00 - 03:00 In the example above, it exceeds 24h since it starts at 02:00 and goes…
4
votes
3 answers

Generate random time within a range of two times with condition

I'm trying to generate 10 random times within a range of two times, and there is a condition that the times generated cannot have less than 30 minutes between them. So, if i Start at 10:00am and end at 05:00pm, the times between these must be a…
4
votes
1 answer

Converting my string to LocalTime with patterns

I wanted to convert my string to LocalTime format String s = "1時30分:00"; String ss = s.replace("時", ":").replace("分", ":"); DateTimeFormatter timeColonFormatter = new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("hh:mm…
Anonymous
  • 477
  • 3
  • 12
4
votes
2 answers

Lock underflow/overflow with Java LocalTime

When subtracting a given amount from a LocalTime object, I've realised that overflow/underflow can occur. Example: 00:30 - 35 minutes = 23:55 23:30 + 35 minutes = 00:05 For my application, I would like lock times such that the above would…
Jordan Mackie
  • 2,264
  • 4
  • 25
  • 45
4
votes
3 answers

C: How to print a particular `time` value in a particular timezone (by offset)?

I'm writing an application in C that parses data files recorded by an external program (over which I have no control). It's storing binary data, one field of which is a time in standard UNIX "epoch" format (seconds since January 1st, 1970,…
lindes
  • 9,854
  • 3
  • 33
  • 45
4
votes
2 answers

Human readable timezone in python?

How can I get human readable timezone from these timeformat in python? And how can I convert the same time to be in that timezone? 'scheduled_datetime': '2017-07-30T10:00:00+05:30' session.scheduled_datetime datetime.datetime(2017, 7, 30, 10, 0,…
shivammahajan
  • 43
  • 1
  • 6
4
votes
5 answers

How to sum two times in Java, using LocalTime?

Example: LocalTime time1 = LocalTime.of(12, 30); LocalTime time2 = LocalTime.of(8, 30); time1 + time2 // Doesn't work. time1.plus(time2) // Doesn't work. I want to get the sum of the two times (12:30 + 8:30 = 21:00) in the format of…
Valio
  • 41
  • 1
  • 4
4
votes
1 answer

Difference between LocalTime and UniversalTime c#

In a recent job interview about C# someone asked me the following question: What is the difference between LocalTime and UniversalTime in c# and when should I use them? After checking the documentation I found the foloowing definition for…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
4
votes
2 answers

PHP getting local date and time

How to get the local date and time in PHP.For example my timezone is Asia/Kolkata. My application has to add the date in my time zone to the database.I know the time can be found by adding 5.30 hrs to UTC time.But what about the date.After some…
Jinu Joseph Daniel
  • 5,864
  • 15
  • 60
  • 90
3
votes
1 answer

localtime() and gmtime() seem to be mucking up my input stream C++/C

I'm having problems converting from unix epoch time to a character array. I know how to do it and the conversion is happening correctly but after I make a call to gmtime() or localtime(), all input gets random characters appended to to. I have…
Tom
  • 155
  • 1
  • 10
3
votes
2 answers

C++: location of localtime_s in GCC

Following the documentation and compiling with gcc-11.2.0 like so g++ -std=c++17 -pthread -O3 -flto -fPIC ... I am not able to use localtime_s in my program: #define __STDC_WANT_LIB_EXT1__ 1 #include using SystemClock =…
S.V
  • 2,149
  • 2
  • 18
  • 41
3
votes
1 answer

How do I get system date and time in oracle sql?

I am using oracle apex when ever I try the code SELECT TO_CHAR (SYSTIMESTAMP) "NOW" FROM DUAL The result is always behind 5 hours. Can any one help me for this query?
sohaib sonu
  • 41
  • 1
  • 3
3
votes
2 answers

Perl convert time in localtime format to YYYYMMDD

I have a string containing a date with this format my $time = 'Fri Jan 8 14:24:27 2016'; And i want to convert it to YYYYMMDD. I tried a couple of options such as : use POSIX qw(strftime); print strftime("%Y%m%d", $time); But it won't work. Tried…
olivierg
  • 728
  • 7
  • 26
3
votes
2 answers

Time.valueOf method returning wrong value

I used the method Time.valueOf to convert the String "09:00:00" into Time object as follows: Time.valueOf (LocalTime.parse("09:00:00")). When I call getTime () to display the value I get: 28800000 ms instead of 32400000‬‬ ms (calculated from…
Nezar1990
  • 43
  • 3
3
votes
2 answers

LocalTime Military Time Parsing 00:00

I've looked at just about all the other posts pertaining to my question without finding a similar issue as mine. I'm trying to get the time between two fields using this code. LocalTime timeFrom = LocalTime.parse("16:00"); LocalTime timeTo =…
exceptionsAreBad
  • 573
  • 2
  • 5
  • 17