Snippets Collections
mydate = input("2020-Jan-04", ANYDTDTE11.); 
const then = new Date('2022-01-24T09:30:20');
const now = new Date();

const msBetweenDates = Math.abs(then.getTime() - now.getTime());

// 👇️ convert ms to hours                  min  sec   ms
const hoursBetweenDates = msBetweenDates / (60 * 60 * 1000);

console.log(hoursBetweenDates);

if (hoursBetweenDates < 24) {
  console.log('date is within 24 hours');
} else {
  console.log('date is NOT within 24 hours');
}
$timestamp = '2014-02-06 16:34:00';
$date = Carbon::createFromFormat('Y-m-d H:i:s', $timestamp, 'Europe/Stockholm');
$date->setTimezone('UTC');
from datetime import datetime

datetime_object = datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')
star

Wed Apr 27 2022 17:22:09 GMT+0000 (UTC)

#format #dates #datastep
star

Fri Dec 17 2021 00:51:34 GMT+0000 (UTC) https://stackoverflow.com/questions/28600330/format-timezone-for-carbon-date

#php #dates #timezone
star

Wed Jan 22 2020 18:52:28 GMT+0000 (UTC) https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime

#python #dates #functions #python3.8

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension