How to convert UNIX time stamps (UTC) to broken-down time?

Advertisements I have broken-down time which I then convert to UNIX timestamp in UTC and without DST with _mkgmtime instead of mktime(which applies the local timezone). This works fine. What I now want is to convert the UNIX timestamp generated back to broken-down time exactly the same with no DST/TimeZone changes. I tried using strftime()… Read More How to convert UNIX time stamps (UTC) to broken-down time?

How to set the time zone with php

Advertisements im trying to set the time in PHP but i don’t know to set the time zone. <?php $currentDateTime = time(); $newDateTime = date(‘h:i A’, strtotime($currentDateTime)); ?> <input type="text" name="time" value="<?php echo $newDateTime; ?>"> >Solution : You can do this by adding the following code: <?php date_default_timezone_set(‘Africa/Johannesburg’); echo date(‘H:i:s’, time()); ?>

how to properly get day of the week (name) with moment.js?

Advertisements Im using https://openweathermap.org/ api. It provides timezone in seconds. How to properly get day of the week (name) using moment.js? const timezoneInMinutes = 7200 / 60; const currentDate = moment().utcOffset(timezoneInMinutes).format("YYYY-MM-DD"); console.log(currentDate) // 2022-05-13 console.log(moment().day(currentDate).format("dddd")); // "Sunday" ???? >Solution : You are putting currentDate into day(), you need to put it on moment(). const timezoneInMinutes… Read More how to properly get day of the week (name) with moment.js?

Earliest and Latest ZonedDateTimes on Earth from an UTC reference time

Advertisements I have a reference ZonedDateTime in UTC: var ref = ZonedDateTime.parse("2022-01-01T14:00Z"); We must find the earliest and latest times on Earth based on the most extreme known TimeZones. That would be: 2022-01-02T04:00+14 2022-01-01T03:00-11 What is the most reliable way to achieve this? I’m thinking about OffsetDateTime, but I’m not sure it will handle daylight… Read More Earliest and Latest ZonedDateTimes on Earth from an UTC reference time

Javascript adding Timezone in my current script

Advertisements i have this code on my script to show ticking clock <script type="text/javascript"> function showTime() { var date = new Date(), time = new Date(Date.UTC( date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds() )); document.getElementById(‘time’).innerHTML = time.toLocaleTimeString(); } setInterval(showTime, 1000); </script> Anyone know how to change the timezone to a specific timezone like "Asia/Jakarta" Thanks before!… Read More Javascript adding Timezone in my current script

subtract time now from gorm create at in golang

Advertisements I am trying to do find the time difference between time now from the created at column in the database I return a row in the database, i have the created_at column with the following time format {"id":1,"email":"fUPvyBA@FApYije.ru","timezone":"pacific time","created_at":"2022-01-23T02:45:01.241589Z","updated_at":"2022-01-23T02:46:01.241591Z"} so created_at = 2022-01-23T02:45:01.241589Z and time.Now() = 2022-01-24 03:24:56.215573343 +0000 UTC m=+1325.103447033 I tested with… Read More subtract time now from gorm create at in golang