Skip to content

Instantly share code, notes, and snippets.

@kam-daniel
Created September 3, 2024 19:40
Show Gist options
  • Save kam-daniel/aea06e9f4388ce36604da72a5b209f2a to your computer and use it in GitHub Desktop.
Save kam-daniel/aea06e9f4388ce36604da72a5b209f2a to your computer and use it in GitHub Desktop.
in codesoft, this formula will return the current unix time as if your timezone is gmt
(((my_year - 1970) * 365) +
((my_year - 1970) / 4) - if(my_year % 4 = 0,1,0) +
IF(my_month > 1, 31, 0) +
IF(my_month > 2, IF((my_year % 4 = 0), 29, 28), 0) +
IF(my_month > 3, 31, 0) +
IF(my_month > 4, 30, 0) +
IF(my_month > 5, 31, 0) +
IF(my_month > 6, 30, 0) +
IF(my_month > 7, 31, 0) +
IF(my_month > 8, 31, 0) +
IF(my_month > 9, 30, 0) +
IF(my_month > 10, 31, 0) +
IF(my_month > 11, 30, 0) +
my_day)*86400 + ({my_hour} * 3600) + ({my_minute} *60) + {my_second}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment