General area when it fits no where else

Moderator: Mmiscool

User avatar
By russm
#48898 Two questions:
1) What is the DST function of timesetup()? The timezone function works but DST has no impact.
2) Is there a way (option) to set a 12 hour clock instead of the default 24 hour clock without manipulating the result string?

I've done a few searches but couldn't find anything on either of these.
User avatar
By forlotto
#48899 Looking at the documentation below I believe all time is military time it is however very possible to convert time simply...
Not so sure about unixtime though to be honest might want to google that portion and see what is possible with unixtime or the differences.


Something like this in plain english you will need to translate to code.
Now you may need to use string functions or time setup to pick out just the time but it shouldn't be impossible not the greatest at code here but with a little work you should be able to get it working!

get the time store data in timeereg
if timeereg is greater than or equal to 13 subtract 12 then print the value
else just print the time as normal

Code: Select alltime():

Will return the date and time as a string.  You can optionally specify the format you want it back in.

Options: month, day, hour, min, sec, year, dow (Day of the week, ex. fri)

time({Optional specification of format})

with an option.

time("year")

time(“year-month-day”) will return “2016-Apr-10”

unixtime():

Permit to convert from a date/time in unix format (a number) to text.

Will return the date and time as a string.  You can optionally specify the format you want it back in.

Options: month, date, hour, min, sec, year, dow (Day of the week, ex. fri)

unixtime({datenumber} , {Optional specification of format})

with an option.

unixtime(1459681200, "year"
timesetup():

Will set up the time time zone and daylight savings attribute.

timesetup({number or var for time zone},{number or var for dst})


I believe this is a javascript example on how to do the conversion:
Code: Select allfunction formatDate(date) {
    var d = new Date(date);
    var hh = d.getHours();
    var m = d.getMinutes();
    var s = d.getSeconds();
    var dd = "AM";
    var h = hh;
    if (h >= 12) {
        h = hh-12;
        dd = "PM";
    }
    if (h == 0) {
        h = 12;
    }
    m = m<10?"0"+m:m;

    s = s<10?"0"+s:s;

    /* if you want 2 digit hours:
    h = h<10?"0"+h:h; */

    var pattern = new RegExp("0?"+hh+":"+m+":"+s);

    var replacement = h+":"+m;
    /* if you want to add seconds
    replacement += ":"+s;  */
    replacement += " "+dd;   

    return date.replace(pattern,replacement);
}

alert(formatDate("February 04, 2011 12:00:00"));
User avatar
By russm
#48934 Thanks, was going to write something myself to manipulate the string if there weren't any display options covering it in time() already.