Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/02/2014, 12:17
gonzaguerini
 
Fecha de Ingreso: febrero-2014
Mensajes: 1
Antigüedad: 10 años, 2 meses
Puntos: 0
Exclamación Hora por TimeZone en mi web

Hola, en mi pagina quiero poner la fecha y hora, pero la hora necesito que sea de un solo lugar, específicamente la GMT-3/UTC-3.. Tengo el siguiente codigo.. Pero me cambia de acuerdo a la hora de mi PC y no me sirve... Puedo trabajar con PHP-Javascript-Etc.. No tengo muchos conocimientos especificos en javascript..

Código HTML:
<script type="text/javascript"><!--

        $(document).ready(function() {
            $("div#clock").simpleClock(-3);
        });
        
        //***** SIMPLECLOCK PLUGIN http://ticktoo.com/blog/35-simpleClock+-+jQuery+Plugin *****/
        (function ($) {

          $.fn.simpleClock = function ( utc_offset ) {

            // Aktuelle Sprache ermitteln
            var language = "es";

            // Tage & Monate in jeweiliger Landessprache
            switch (language) {
                case "es":
                    var weekdays = ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"];
                    var months = ["Ene", "Feb", "Mar", "Abr", "Mayo", "Jun", "Jul", "Ago", "Sept", "Oct", "Nov", "Dic"];
                    break;
            }

            var clock = this;

            // getTime - Where the magic happens ...
            function getTime() {
              var date = new Date();

              var nowUTC = date.getTime() + date.getTimezoneOffset()*60*1000;

              // alert( nowUTC +' vs. '+ date.getTime() );

              // Zeitverschiebung addieren/subtrahieren: X STD * 60 Min. * 60 Sek. * 1000 Millisek.
              date.setTime( nowUTC + (utc_offset*60*60*1000) );

              var hour = date.getHours();

                ///// AM, PM für Language "en"
                if ( language == "en" ) {
                    //it is pm if hours from 12 onwards
                    suffix = (hour >= 12)? 'p.m.' : 'a.m.';

                    //only -12 from hours if it is greater than 12 (if not back at mid night)
                    hour = (hour > 12)? hour -12 : hour;

                    //if 00 then it is 12 am
                    hour = (hour == '00')? 12 : hour;
                }

              return {
                day: weekdays[date.getDay()],
                date: date.getDate(),
                month: months[date.getMonth()],
                year: date.getFullYear(),
                hour: appendZero(hour),
                minute: appendZero(date.getMinutes()),
                second: appendZero(date.getSeconds())
              };
            }

            // appendZero - If the number is less than 10, add a leading zero. 
            function appendZero(num) {
              if (num < 10) {
                return "0" + num;
              }
              return num;
            }

            // refreshTime - Build the clock. now.year
            function refreshTime(clock_id) {
                var now = getTime();
                clock = $.find('#'+clock_id);
                $(clock).find('.date').html(now.day + ' ' + now.date + ' ' + now.month);
                $(clock).find('.time').html("<span class='hour'>" + now.hour + "</span>:<span class='minute'>" + now.minute + "</span>:<span class='second'>" + now.second + "</span>");

                if ( typeof(suffix) != "undefined") { // am oder pm ?
                    $(clock).find('.time').append('<strong>'+ suffix +'</strong>');
                }
            }

            // Get individual clock_id
            var clock_id = $(this).attr('id');

            // Tick tock - Run the clock.
            refreshTime(clock_id);
            setInterval( function() { refreshTime(clock_id) }, 1000);    

          };
        })(jQuery);
    //--></script>
<div class="date"></div>
        <div class="time"><span class="hour"></span>:<span class="minute"></span>:<span class="second"></span></div> 
Si tuviera que cambiar todo el codigo no hay problema XD, necesito que aparezca de la sig forma por ej... LUN 01 ENE 11:30:59
Graciass..