Author Topic: convert epoch time  (Read 11930 times)

Script_test

  • Newbie
  • *
  • Posts: 37
convert epoch time
« on: October 03, 2016, 04:14:11 AM »
Hello
have any function to convert epoch time to human readable format?
ty

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: convert epoch time
« Reply #1 on: October 03, 2016, 11:24:56 AM »
Take a peek at  the FORMATDATE() function.
Script BASIC Project Manager

Script_test

  • Newbie
  • *
  • Posts: 37
Re: convert epoch time
« Reply #2 on: October 24, 2016, 08:06:10 AM »
exactly what I'm looking for.
Code: [Select]
print NOW

This function returns the local time expressed as seconds since January 1, 1970, 00:00am. The function does not accept any argument. This function is similar to the function GMTIME but returns the local time instead of the actual GMT.

thanks for your help! ;)
https://en.wikipedia.org/wiki/Unix_time

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: convert epoch time
« Reply #3 on: October 24, 2016, 12:37:34 PM »
Code: Script BASIC
  1. FormatDate("format",time)
  2.  

Arguments

format is a string using the formatting characters described in the docs.

time can be NOW or any other number of seconds past Jan. 1, 1970.

It's really easy to do date math in Script BASIC.
« Last Edit: October 24, 2016, 06:28:07 PM by support »
Script BASIC Project Manager

Script_test

  • Newbie
  • *
  • Posts: 37
Re: convert epoch time
« Reply #4 on: October 25, 2016, 12:05:33 AM »
exactly what I'm looking for.
Code: [Select]
print NOW

This function returns the local time expressed as seconds since January 1, 1970, 00:00am. The function does not accept any argument. This function is similar to the function GMTIME but returns the local time instead of the actual GMT.

thanks for your help! ;)
https://en.wikipedia.org/wiki/Unix_time

But, How can I get the number of milliseconds ?

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: convert epoch time
« Reply #5 on: October 25, 2016, 12:40:32 AM »
Script BASIC only has a resolution of 1 second. I created a millisecond resolution timer using the SDL_gfx extension module.
Script BASIC Project Manager

Script_test

  • Newbie
  • *
  • Posts: 37
Re: convert epoch time
« Reply #6 on: October 25, 2016, 06:21:09 AM »
how to convert in milliseconds GMTIME*1000?
Code: [Select]
print GMTIME,"\n"
print GMTIME*1000,"\n"

->

1477401476
1.477401e+012

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: convert epoch time
« Reply #7 on: October 25, 2016, 01:59:21 PM »
Like I said, Script BASIC only has 1 second resolution. The number you're getting back from NOW or GMTIME is seconds past Jan. 1, 1970 00:00 AM. You need to do milliseconds function in an extension module like I did with SDL_gfx or IMPORT it.


« Last Edit: October 25, 2016, 06:26:03 PM by support »
Script BASIC Project Manager

Script_test

  • Newbie
  • *
  • Posts: 37
Re: convert epoch time
« Reply #8 on: November 10, 2016, 05:37:25 AM »
Understood, sorry... thanks for your patience. :-[