I'd like to format a date field in my search results. Handlebars doesn't support this natively and I can't find any documentation stating if Gamesparks provides any handlebars helpers or any way to make my own.
Do I have to loop over my objects in serverside JS and format the date fields? That's the only obvious way I'm seeing, but I'd like to be able to use a handlebars helper to do this.
Best Answer
C
Customer Support
said
over 3 years ago
Hi Arnold In your search results snippet you can format the date in the javascript/cloud code section. For example
In javascript/cloud code section.
var players = []; var results = playerCollection.find(query, {"displayName" : 1,"date":1}).limit(limit); for ( var i in results) { var myResults = results[i]; var parseDate = parseInt(myResults.Date); var newDate = new Date(parseDate); var gmtDate = newDate.toGMTString(); players.push({displayName:myResults.displayName,Date:gmtDate}); } form.players = players;
Hi Arnold In your search results snippet you can format the date in the javascript/cloud code section. For example
In javascript/cloud code section.
var players = []; var results = playerCollection.find(query, {"displayName" : 1,"date":1}).limit(limit); for ( var i in results) { var myResults = results[i]; var parseDate = parseInt(myResults.Date); var newDate = new Date(parseDate); var gmtDate = newDate.toGMTString(); players.push({displayName:myResults.displayName,Date:gmtDate}); } form.players = players;
Arnold V
I'd like to format a date field in my search results. Handlebars doesn't support this natively and I can't find any documentation stating if Gamesparks provides any handlebars helpers or any way to make my own.
Do I have to loop over my objects in serverside JS and format the date fields? That's the only obvious way I'm seeing, but I'd like to be able to use a handlebars helper to do this.
In your search results snippet you can format the date in the javascript/cloud code section.
For example
In javascript/cloud code section.
var players = [];
var results = playerCollection.find(query, {"displayName" : 1,"date":1}).limit(limit);
for ( var i in results)
{
var myResults = results[i];
var parseDate = parseInt(myResults.Date);
var newDate = new Date(parseDate);
var gmtDate = newDate.toGMTString();
players.push({displayName:myResults.displayName,Date:gmtDate});
}
form.players = players;
}
In HTML / GSML section.
{{#each results.players}}
<hr/>
<gs-row>
<gs-col width="4">{{displayName}}</gs-col>
<gs-col width="4">{{Date}}</gs-col>
<gs-col width="1"><gs-link snippet="player_master?playerId={{_id.$oid}}" target="modal-large"><i class="icon-edit"/></gs-link></gs-col>
</gs-row>
{{/each}}
Thanks Katie
Customer Support
In your search results snippet you can format the date in the javascript/cloud code section.
For example
In javascript/cloud code section.
var players = [];
var results = playerCollection.find(query, {"displayName" : 1,"date":1}).limit(limit);
for ( var i in results)
{
var myResults = results[i];
var parseDate = parseInt(myResults.Date);
var newDate = new Date(parseDate);
var gmtDate = newDate.toGMTString();
players.push({displayName:myResults.displayName,Date:gmtDate});
}
form.players = players;
}
In HTML / GSML section.
{{#each results.players}}
<hr/>
<gs-row>
<gs-col width="4">{{displayName}}</gs-col>
<gs-col width="4">{{Date}}</gs-col>
<gs-col width="1"><gs-link snippet="player_master?playerId={{_id.$oid}}" target="modal-large"><i class="icon-edit"/></gs-link></gs-col>
</gs-row>
{{/each}}
Thanks Katie
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2346 topics