How to add data of date type to database

This forum contains topics that were moved from Get Satisfaction
Claes Dahlberg
Posts: 0
Joined: Tue Oct 21, 2014 3:40 pm

How to add data of date type to database

Post by Claes Dahlberg »

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

Post by Kateryna Grynko »

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

Post by Yang Mega »

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

Post by Alena Prykhodko »

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

Post by M&M »

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

Post by M&M »

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

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

Post Reply