Friday 15 August 2014

javascript - Transform function using Momentjs -



javascript - Transform function using Momentjs -

its there way transform function moment.js? 70% js , 30% moment.js

function

function muestradias() { var day=0; var server = timesync.servertime() // var d= new date(); var weekdays = new array(7); weekdays[0] = "domingo"; weekdays[1] = "lunes"; weekdays[2] = "martes"; weekdays[3] = "miercoles"; weekdays[4] = "jueves"; weekdays[5] = "viernes"; weekdays[6] = "sabado"; (i=1; i<8;i++){ document.getelementbyid("sub"+i).innerhtml = moment(d).locale("es").format('l'); day=weekdays[d.getday()]; // document.getelementbyid("titulo"+i).innerhtml =day; document.getelementbyid("fecha"+i).innerhtml = moment(d).locale("es").format('lll'); d.setdate(d.getdate() +1); // need alter functionality moment } }

alredy seek remove d variable, for stop working, perchance alter function total moment.js same functionality?

first place on rendered function

meteor.call('tomafecha',function(error,fecha){ if(error){ console.log("no se pudo mostrar la fecha"); } else { dia = moment(fecha).locale("es"); var d = dia; (i=1; i<8;i++){ document.getelementbyid("sub"+i).innerhtml = d.format('l'); document.getelementbyid("titulo"+i).innerhtml = d.format('dddd'); // document.getelementbyid("dia"+i).innerhtml = d.format('dddd'); //document.getelementbyid("fecha"+i).innerhtml = d.format('lll'); d.add(1,'days'); } } });

also utilize meteor.call, server time, , ignore browser time

server.js

meteor.methods({ tomafecha : function(){ var d = (new date()) homecoming d; } })

and works

javascript html meteor momentjs

No comments:

Post a Comment