Claes Dahlberg
Posts: 0
Joined: Tue Oct 21, 2014 3:40 pm

How to add data of date type to database

I wan't to add a current date when posting new item to appery database.
I've done a mapping of the fields and for the date field I've tried the following java script instead of mapping line:

var d=new Date();
return d.toISOString().replace("T"," ").replace("Z","");

This doesn't work and I don't know how! Please help!
/Claes

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to add data of date type to database

Hi Claes,

Please try without editing the string: prevar date = new Date();
return date.toISOString();/pre

Yang Mega
Posts: 0
Joined: Sun Aug 31, 2014 6:08 am

How to add data of date type to database

The above have a timezone problem!!! Do we have better solution ?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to add data of date type to database

Could you please clarify what exactly are you trying to do?

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

How to add data of date type to database

If you want a string representation of a "UTC" or unix timestamp, this is what you need

var UTCstring = (new Date()).toUTCString();

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

How to add data of date type to database

If you want a string representation of a "UTC" or unix timestamp, this is what you need

var UTCstring = (new Date()).toUTCString();

Return to “Issues”