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
2
votes
1 answer

PostgreSQL - extracting date ranges in local time?

CURRENT SITUATION: I have a table of wildfire incidents with a timestamp with time zone (timestamptz) field to track when the observation occurred. Everything in the data creation process is in UTC: the incoming data from the source, the app…
David A
  • 47
  • 7
2
votes
3 answers

Java Convert UTC Date to local Date with Joda

This code is working, but I want to use Joda-Time public static Date dateFromUTC(Date date){ return new Date(date.getTime() + Calendar.getInstance().getTimeZone().getOffset(date.getTime())); } I tried this, but it's not working - what's…
SpamSajt
  • 21
  • 2
2
votes
3 answers

How do I convert a datetime in UTC to the server's local time using AT TIME ZONE in SQL Server 2016+

Using SQL Server 2016 or newer, I want to convert a datetime that represents a UTC value to local time on the server. I would like to use AT TIME ZONE but it assumes you explicitly know what the server's time zone is. Our product may be installed…
Frogger
  • 94
  • 8
2
votes
3 answers

Determining Local Time in another Timezone

How can I determine the current date and time of various countries using a PERL script that executes on a server in the US? For example, getDTnow() should determine the current date and time on the server and use that to return the date and time of…
Sam
  • 1,358
  • 4
  • 16
  • 30
2
votes
2 answers

measure time difference

I want to measure in milliseconds how much time there is between when I start my application and another time, for example 16:00 o'clock. What is the best way to do this? I looked around "clock" function but it's not what I need. Operating system:…
Tom
  • 9,275
  • 25
  • 89
  • 147
2
votes
0 answers

same date when printing from st_mtime, st_ctime,st_atime

So, I'm supposed to print the date of access of directories, modification and creation, but they all seem to be the same date. Here's my code: struct* tm date; struct stat fileStat; if(options[0] == 1 && options[1] == 0 && options[2] == 0 &&…
Jose A
  • 31
  • 6
2
votes
1 answer

Perl function localtime giving incorrect values for years between 1964 and 1967

I was getting some whacky values from localtime function in Perl. The following is some code for which I get incorrect values. In particular, this code is meant to determine the weekday for the first of each year. #!/usr/bin/perl use strict…
A.Ellett
  • 331
  • 2
  • 10
2
votes
2 answers

LocalTime object - Add leading zero to the minutes

I am trying to create an object of the Java class LocalTime like this: LocalTime beginning = LocalTime.of(int hours, int minutes); My problem is that I would like that my user could input the time in the following format: HH:MM However, when…
CWhite
  • 185
  • 2
  • 3
  • 9
2
votes
1 answer

Optional seconds when serializing NodaTime.LocalTime?

Is it possible to make a pattern for NodaTime's LocalTime, which matches the ISO 8601 standard for times? That is, can you make (minutes and) seconds optional, like you can make fractional seconds optional? I wish to be able to always have hours and…
Mikkel R. Lund
  • 2,336
  • 1
  • 31
  • 44
2
votes
2 answers

How to solve localtime_r timezone segmentation fault?

I was using localtime on my BeagleBone Black to time stamp events. I'm running a multi-threaded application and realized that localtime is not thread safe. So I switched to localtime_r and this generates a segmentation fault. Please find attached…
am3
  • 681
  • 2
  • 12
  • 30
2
votes
1 answer

Unix timestamp to Local date in moment-timezone

I have a unix timestamp which I want to convert to local time using moment-timezone library. I am not sure how to do it. Couldn't find anything. Anyone has any ideas? I tried this but it isn't giving correct local…
Nikhil Tikoo
  • 365
  • 1
  • 9
  • 31
2
votes
2 answers

localtime_s and strftime usage building ISO time string

I´ve wrote the following function that receives a time point and return a ISO string with milliseconds: std::string TimePointToISOString(const std::chrono::time_point& time) { std::time_t rawTime =…
Mendes
  • 17,489
  • 35
  • 150
  • 263
2
votes
2 answers

Working with DateTime Time Zones

I am writing some code where I have a DateTime in UTC and I need to display this as a LocalTime where I have a Culture object for two timezones. Here is my code: public void CultureDateTimeLocalTime() { DateTime dateTimeUtcNow =…
Simon
  • 7,991
  • 21
  • 83
  • 163
2
votes
2 answers

Java 8 time: Iterate over a day's LocalTime in period steps

Starting at midnight, I want to iterate over LocalTimes in steps of a certain period length to the end of the day. Eg. if the period is 8hr10Minutes I would like times: 0:00, 8:10, 16:20 (not 24:30 as this is the next day) I have the following…
Philipp
  • 4,659
  • 9
  • 48
  • 69
2
votes
1 answer

Converting localtime to time_t (C++)

I creating date() function on C++ http://aliarth.lt/date.cpp and I got one problem with localtome_to_time() conversion. Does anyone know how that local_time variable: int time_integer = 12345; time_t time = (time_t)time_integer; tm *local_time =…
Alivat
  • 51
  • 9