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
1
vote
2 answers

perl strftime localtime minus 12 hours

I im using perl strftime for (datetime now) perl -MPOSIX -e 'print POSIX::strftime("%m/%d/%Y %H:%M", localtime());' i want to minus datetime now by 12 hour Example OUTPUT: 2/7/2020 1:00 to 2/6/2020 13:00 <- minus 12 hours only Please help to solve…
Drin
  • 21
  • 4
1
vote
1 answer

Accurate Timestamps using gettimeofday and localtime

I'm attempting to monitor system time elapsed across multiple applications and data paths via gettimeoday and localtime. In this example, I want to grab the system time (microsecond percision) right before my code runs. I'm currently doing it like…
fbd39j
  • 35
  • 2
  • 4
1
vote
2 answers

"... is not public in org.bp.threeten.format.DateTimeFormatter" error when trying to turn String to LocalDate

I'm trying to turn a String into LocalDate using this code: String end = sharedPref.getString("endDate", "Not available"); DateTimeFormatter formatter = new DateTimeFormatter("yyyy-MM-dd"); LocalDate endDate = LocalDate.parse(end, formatter); But…
Tashila Pathum
  • 109
  • 2
  • 11
1
vote
1 answer

is it possible to determine local time of the machine from which an api request is made?

I want to know the current time of the machine from which a request is made to my api written in java. Is it possible to do that using some function of HttpServletRequest?
prachi
  • 109
  • 1
  • 10
1
vote
0 answers

How do I insert timezone variable into DateTimeZone?

I have this piece of code $timezone = 'America/New_York'; $now = new DateTime(); $now->setTimezone(new DateTimeZone('America/New_York')); echo $now->format('Y-m-d h:i:s'); The above code works. But I want the $timezone variable to replace…
1
vote
1 answer

Convert localtime in seconds since epoch to UTC

In my system I have a PC (Linux, in case it matters) which keeps RTC time in UTC, making my localtime timezone specific. In PC code, I get UTC time as seconds since epoch using struct timespec tv; clock_gettime(CLOCK_REALTIME, &tv); double time =…
Paul Grinberg
  • 1,184
  • 14
  • 37
1
vote
1 answer

Convert UTC time to local time in django

How can I convert to from UTC time to local time? Here is the format from frontend: Tue Sep 10 2019 00:00:00 GMT+0800 (Singapore Standard Time) This is the print result from Django: 2019-09-09T16:00:00.000Z This is how I convert to local time :…
Arkar
  • 53
  • 1
  • 6
1
vote
2 answers

java.time: the simplest way to get a difference in hours between two LocalTime objects

I want to get a difference in hours between a current time in a specific timezone and UTC time. I tried this: LocalTime time = LocalTime.now(); System.out.println(time); //21:05:42:764 LocalTime utcTime = LocalTime.now(ZoneId.of("UTC")); …
parsecer
  • 4,758
  • 13
  • 71
  • 140
1
vote
1 answer

How to manipulate Ranges of Time of a Day

I'm working with an agenda in Java. I have stored in my database the day of the week, the start and end time of some labs availability. Now I need to provide a service for a schedule system by showing only the unavailable times of the day. For…
Andre
  • 431
  • 7
  • 23
1
vote
1 answer

Pyephem localtime issue

I have a time lapse python script that works fine in the uk, it now I live in France it’s still calculating on standard GMT time. How can I change the code so it represents my actual location? import sys import os import time import ephem #find…
Lmm Cams
  • 21
  • 2
1
vote
2 answers

Moment JS showing 1 hour of difference in some PC

I dont know why, but in some PCs the momentjs show a wrong time. I belive this caused by daylight summer (current here in my country). But in a few PCs show correctly and anothers with 1 hour of difference (like this print screen). Apparently the…
Márcio Rossato
  • 971
  • 1
  • 11
  • 20
1
vote
0 answers

How to LocalDateTime but use server time or internet time?

I have been using Java 11 LocalDateTime but realised that it uses the time of the system. Are there alternatives that allow me to use the system time of a server or web time in my country? Edit: After trying Instant I am very close to result I am…
Tom
  • 21
  • 1
  • 7
1
vote
1 answer

localtime() is off by about 460,000 years on RTL8710

I'm using an RTL8710 (running rustl8710, but that's irrelevant as far as this question goes, since all code I'm talking about is C code). The RTL8710 has proprietary libraries for some parts of the system, including localtime. However, localtime…
cmpxchg8b
  • 661
  • 5
  • 16
1
vote
3 answers

How do you get local time and do not update it when time changes?

I have to get the Localtime of UTC+5:45. I found the code and implemented it but the time gets updated when the as time progresses. How to get it fixed without updating? This is the code that I have implemented: Date localTime = new Date(); …
1
vote
1 answer

localtime, mktime: second normalization and DST behaviour

Take the following piece of code: static void printTime(const struct tm* t, const time_t stamp){ printf("%d-%d-%d, %d:%d:%d (DST %s) (stamp: %zu)\n", 1900 + t->tm_year, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,…
Cheiron
  • 3,620
  • 4
  • 32
  • 63