Finally solve it with joshowens: timezone-picker adding the package can get the client's time usage and there implement the logic with moments to convert the server time with the client's time.
I have a little problem for the handling of schedules my scenario: I am working with a reminder system which will be activated through the push notifications when the reminder is fulfilled acitva a call to perform the push alert. To save the dates of the users I am using creatAt = new date which I am in the field of the user database. Where it returns me as format Mon Apr 17 2017 18:14:34 GMT-0430 (Venezuela Standard Time), but on the server where I have hosted it uses GMT + 0000 which if the user is in another country the GMT is going to vary Always creating a difference either above or below the server time. I thought I would use moment-timezone to set the time of the user at the time of the query moment (). Tz ("America / Los_Angeles"). Format () But I do not know if it is the best way, I leave a copy of the code.
upgrade
Then follow the suggestions to implement moments to synchronize the time of my users with that of the server I have not been able to perform such task. I would appreciate if someone gives me a hand and guides me how I could do it. I leave my code which I have the precolate-cronjobs library to start the timer that will allow me to execute the activation of the push notifications to the users when the reminders finish their period. Handling 3 cases which is what indicates the times that should be reflected if daily, weekly or monthly. The user through the interface is the one that indicates when they should be met with indicating the time and number of times as (daily, weekly , monthly)
/*remminder.js*/
import moment from 'moment';
SyncedCron.add({
name: 'Recordatorio Personas',
schedule: function(parser) {
return parser.text('every 10 seconds');
},
job: function(intendedAt) {
Meteor.call('timer1', intendedAt);
}
});
Meteor.startup(function () {
SyncedCron.start();
console.log("iniciando..")
});
/*timer.js*/
import { Meteor } from 'meteor/meteor';
import moment from 'moment';
import momentT from 'moment-timezone';
Meteor.methods({
timer1: function(timer){
//console.log("metodos Timer",timer);
var data = AddPerson.find({ id: this.userId}).fetch();
for (var i = 0; i < data.length; i++) {
/****************GLOBAL************************/
console.log('/*Server logs CronJobs*/')
//var timerD = moment(timer).format('HH:mm');
var s = momentT.tz.guess();
var TimerD = momentT.tz(timer, s).format('HH:mm');;
var createdAt=data[i].createdAt;
var m =moment.utc(createdAt).format('YYYY-MM-DD');
var mh= m +' '+ data[i].hora;
var mhutc = momentT.tz(mh, s).format('HH:mm');
var dateTime= new Date();
console.log('hUser:',data[i].hora);
console.log('DateSistema:', dateTime)
console.log('mh:', mh);
console.log('s:',s);
console.log('mhutc',mhutc);
console.log('m',m);
console.log('timerCron:', timer);
console.log('convertTimer:',TimerD);
console.log('/****end logs*****/');
/****************GLOBAL***********************/
/****************Daily************************/
if (data[i].recordatorio === 'Diario' || data[i].recordatorio === 'Daily'){
if (TimerD === data[i].hora) {
console.log("STOP Send Push")
Meteor.call("serverNotification");
} else {
console.log('contando.');
}
}
/*****************Weekly************************/
if (data[i].recordatorio === 'Semanal' || data[i].recordatorio === 'Weekly' ){
var timerSemanal= moment(data[i].createdAt).day();
var timerS = moment(timer).day();
if (TimerD === mhutc && timerSemanal === timerS) {
console.log("STOP Enviar Push")
Meteor.call("serverNotification");
} else {
console.log('contando.');
}
}
/*****************Monthly************************/
if (data[i].recordatorio === 'Mensual' || data[i].recordatorio === 'Monthly'){
var TimerMes= moment(timer).date();
var timerM = moment(timer).date();
if (TimerD === data[i].hora && timerMes === timerM) {
console.log("STOP Enviar Push")
Meteor.call("serverNotification");
} else {
console.log('contando.');
}
}
/*****************end************************/
}
}
})