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
9
votes
4 answers

Convert local time (10 digit number) to a readable datetime format

I'm working with pbx for voip calls. One aspect of pbx is that you can choose to receive CDR packages. Those packages have 2 timestamps : "utc" and "local", but both seem to always be the same. Here's an example of a timestamp : "1268927156". At…
Terry
  • 5,132
  • 4
  • 33
  • 66
9
votes
2 answers

How to get the difference between two JodaTime LocalTime stamps?

I am using JodaTime LocalTime in order to specify times. How can I get the difference in minutes between two times? LocalTime startT = new LocalTime(6,30); LocalTime endT = new LocalTime(12,15); // LocalTime duration =…
Klausos Klausos
  • 15,308
  • 51
  • 135
  • 217
8
votes
2 answers

Checking if LocalDateTime falls within a time range

I have a time A which should fall within 90 minutes range of timeB (before and after). Example: if timeB is 4:00 pm , time A should be between 2:30pm (-90) to 5:30pm (+90) Tried the following : if(timeA.isAfter(timeB.minusMinutes(90)) ||…
Rk R Bairi
  • 1,289
  • 7
  • 15
  • 39
7
votes
2 answers

c++ localtime when changing timezone

I have a setup working using localtime() to get a tm with the local times represented in it. And that is all good. However, if I change timezone while the application is running, it does not notice that I have changed timezones. Is there some way…
Jon
  • 1,013
  • 1
  • 10
  • 17
7
votes
2 answers

How to generate a random time between two times say 4PM and 2AM?

I have tried using - int startSeconds = restaurant.openingTime.toSecondOfDay(); int endSeconds = restaurant.closingTime.toSecondOfDay(); LocalTime timeBetweenOpenClose = LocalTime.ofSecondOfDay(ThreadLocalRandom.current().nextInt(startSeconds,…
7
votes
4 answers

How quickly is CRON triggered?

First Example Suppose I have a CRON job 30 2 * * * .... Then this would run every time when it is 2:30 at night (local time). Now suppose I have the time zone Europe/Germany and it's 2017-10-29 (the day when DST is switched). Then this CRON job…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
7
votes
1 answer

How to store LocalTime in hibernate

I have an entity that has a variable of type LocalTime and I would like to store it in database. So I have two questions: What data type will the field in mysql be? What annotation to use for entity? I do not care for date at all whatsoever.
Quillion
  • 6,346
  • 11
  • 60
  • 97
7
votes
1 answer

When does a Perl script need to call `tzset` before calling `localtime`?

I recently learned how to change the timezone returned by localtime in Perl. use POSIX qw(tzset); print localtime . "\n"; $ENV{TZ} = 'America/Los_Angeles'; print localtime . "\n"; tzset; print localtime . "\n"; Outputs Wed Apr 15 15:58:10 2009 Wed…
700 Software
  • 85,281
  • 83
  • 234
  • 341
6
votes
1 answer

Convert to local time zone from latitude and longitude R

I have one data frame with a lot of locations (around 30.000), and I need to convert the time of each location for the local time. I tried some ideas like this one, and this one. But they did not work for me. I have data like this: dt =…
6
votes
0 answers

Saving a LocalTime in MySql TIME column

Backstory I recently came across a problem with saving a LocalTime to a TIME column in a MySQL database. Saving a value of 9:00 was causing 8:00 to be saved in the database. This problem did not occur on my dev environment (Windows), but did occur…
PMah
  • 686
  • 5
  • 24
6
votes
2 answers

Time zone in date?

From where does the date command in Linux get the time zone information? I cannot see the /etc/localtime file and the /usr/share/zoneinfo directory on my system. Still, when I execute the date command, I get the following output: Thu Dec 9…
nitin_cherian
  • 6,405
  • 21
  • 76
  • 127
6
votes
2 answers

Java LocalTime Parse Exception

I had a piece of code that worked just fine and now somehow doesn't work. I am reading in a csv file and get an error when reading in a time field of the format 4:38. My code that throws the exception is: LocalTime.parse("4:38",…
k88
  • 1,858
  • 2
  • 12
  • 33
6
votes
2 answers

How do I convert epoch time to normal time in Perl?

I am attempting to write a Perl script that parses a log where on each line the second value is the date. The script takes in three arguments: the input log file, the start time, and the end time. The start and end time are used to parse out a…
Matt Pascoe
  • 8,651
  • 17
  • 42
  • 48
6
votes
4 answers

How to find next day's Unix timestamp for same hour, including DST, in Python?

In Python, I can find the Unix time stamp of a local time, knowing the time zone, like this (using pytz): >>> import datetime as DT >>> import pytz >>> mtl = pytz.timezone('America/Montreal') >>> naive_time3 = DT.datetime.strptime('2013/11/03',…
eepp
  • 7,255
  • 1
  • 38
  • 56
5
votes
2 answers

Does localtime return a heap allocated tm*

As you know the standard header defines the struct tm and a function called localtime. Does localtime make a heap allocation? Or is it allocated in the stack? It returns a pointer but this could be just a pointer to the stack value, right?
trianglx
  • 89
  • 5
1 2
3
30 31