My 1st script

  • Twister360
  • Born
  • Born
  • Twister360
  • Posts: 2

Post 3+ Months Ago

This is my 1st script any one here can help me and fix my script;im new this one i want learn more about that :(

    twis = new Date();
    var h24 = twis.getHours();
    var m = twis.getMinutes();
    var s = twis.getSeconds();

    if (h24<10){h_24="0"+h24;}else{h_24=h24}
    if (m<10){m="0"+m;}
    if (s<10){s="0"+s;}

    var uh = twis.getUTCHours();
    var um = twis.getUTCMinutes();
    var us = twis.getUTCSeconds();

    if (uh<10){h_uh="0"+uh;}else{h_uh=uh;}
    if (um<10){um="0"+um;}
    if (us<10){us="0"+us;}

    if (uh>=12){uk=uh-12;}else{uk=uh+0;} /*universal time 24hrs to 12hrs*/
    if (uk>12){ukt=uk-1;}else{ukt=uk+1;} /*Universal time added GMT +0100 in 12hr UK*/
    if (uh>ukt-1){uk_ampm="PM";}else{uk_ampm="AM";}/*AM and PM display*/
    if (ukt<10){h_uk1="0"+ukt;}else{h_uk1=ukt;}/*if less then 10 put "0' in front become 00*/
    if (h_uk1==0){h_uk="12";}else{h_uk=h_uk1;}

    if (uh>=12){usa=uh-12;}else{usa=uh+0;}
    if (usa>=12){usat=usa+6;}else{usat=usa+6;}/*Universal time subed GMT -0600 in 12hrs USA central*/
    if (uh>usat+6){usa_ampm="PM";}else{usa_ampm="AM";}
    if (usat<10){h_usat="0"+usat;}else{h_usat=usat;}
    if (h_usat==0){h_usa="12";}else{h_usa=h_usat;}

    if (h24>12){h = h24-12;}else{h =h24+0;}/*Time local Formula 24hrs to 12hrs*/
    if (h24>12){ampm = "PM";}else{ampm = "AM";}
    if (h<10){ha="0"+h;}else{ha=h}
    if (ha==0){ha1="12";}else{ha1=ha;}/*jika sama 0==0 jadi kna true atau on*/

    time.text = ha1+":"+m+":"+s+" "+ampm;/* local Time In 12hrs Display*/
    time_24.text = h_24+":"+m+":"+s+" HR";/*local times in 24hrs Display*/
    time_uk.text =h_uk+":"+um+":"+us+" "+uk_ampm;/* UK time zone display*/
    time_usa.text = h_usa+":"+um+":"+us+" "+usa_ampm;/*Usa time zone display*/
    time_utime.text =h_uh+":"+um+":"+us+" HR"; /*Universal Time display*/

any 1 can fix my script please and why i got crazy output I know im newbie :roll: :( >.<...Btw thx alot
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

ahhh whats it supposed to do and what isn't it doing?
  • Twister360
  • Born
  • Born
  • Twister360
  • Posts: 2

Post 3+ Months Ago

i try made simple time UTCtime in uk and usa into 12hrs can u help me to fix this i got lot problem lik AM PM ... :(
  • Flanders
  • Beginner
  • Beginner
  • User avatar
  • Posts: 48
  • Loc: Reno, Nevada US

Post 3+ Months Ago

You should look into the date() functions and use it's unix date feature. I've used it in php and it works wonders for dealing with date/time functions. Calculation for date and time becomes a snap.
60 seconds
60*60 = 3600 seconds (1 hour)
3600*24 = 86400 (24 hours - 1 day)

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 2 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.