Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Appery 'server' time

I'm wirting an app that will be sending emails from a server script (or so I plan).

I'm finding all of the fun issues about converting local dates on phones & desktops to UTC date in Javascript.

As I head into writing the server code to find the emails that need to be sent - I'm planning on using a field on my database that stores the UTC time of the email to be sent.

So - planning ahead - if I have a server script that runs say 1x per minute - and queries my db for emails that need to be sent - based on UTC timestamp - will the server respond with UTC times for which to query against?

Any advice on how I might write the server side code? Any examples that are public out on this forum that you are aware of?

thanks!
Bruce

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Appery 'server' time

Hi Bruce,

I guess workflow for your logic could be:

  1. Run server script with needed interval.

  2. In the script you get current date (GMT/UTC) with following js code:

    precode

    //Here is PST timeZone.
    var date = new Date();

    //Here is GMT/UTC time zone.
    var goalDate = date.toISOString();

    //Now you can use this date in the query to db to "Date" type fields.
    console.log("goalDate = " + goalDate);

    /code/pre

  3. Use goalDate - to make query to DB with "$gt" or/and "$lt" clauses.
    More info about these clauses here: http://devcenter.appery.io/documentat...

    Regards.

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Appery 'server' time

Yurii,

thanks much - this gives me plenty to think about - appreciate it. I'm sure I'll have 1 or 2 questions as I go along.... but... time to get started so thanks!

I've found the magic items as you pointed out above - the ISOString is key in storing the dates and again on doing queries.... how to determine timezoneoffset, date math (using milliseconds... ) , et al. Good pointers...

thanks again,
Bruce

Return to “Issues”