ScriptBasic

Support => General Discussions => Topic started by: Script_test on October 03, 2016, 04:14:11 AM

Title: convert epoch time
Post by: Script_test on October 03, 2016, 04:14:11 AM
Hello
have any function to convert epoch time to human readable format?
ty
Title: Re: convert epoch time
Post by: Support on October 03, 2016, 11:24:56 AM
Take a peek at  the FORMATDATE() (http://www.scriptbasic.org/docs/ug/ug_25.65.1.html) function.
Title: Re: convert epoch time
Post by: Script_test 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
Title: Re: convert epoch time
Post by: Support 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.
Title: Re: convert epoch time
Post by: Script_test 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 ?
Title: Re: convert epoch time
Post by: Support 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.
Title: Re: convert epoch time
Post by: Script_test 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
Title: Re: convert epoch time
Post by: Support 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.


Title: Re: convert epoch time
Post by: Script_test on November 10, 2016, 04:37:25 AM
Understood, sorry... thanks for your patience. :-[