I have a very strange problem because some weeks ago, all worked well. But now, I cannot save a object containing a Date.
I use the Parse.com backend. I have a very simple class with just one field Date.
I do a very simple query :
var Day = Parse.Object.extend('Day');
var d = new Day();
var now = new Date();
d.set('dateField', now);
d.save();
I get an error :
invalid type for key dateField, expected date, but got string
if I try to do that :
d.set('dateField', {__type:"Date", iso:now.toISOString()}
I've got the same problem...
I hope somebody can help me, because, I have not any idea...
Thanks !
Don't know what are you doing wrong there but this snippet works correctly for me. It is tested & working correctly.
Quick double check which you can make - COLUMN NAME of CLASS, NAME of CLASS, DATATYPE of the COlUMN, JS SDK version in SCRIPT TAG
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.3.2.min.js"></script>
<script type="text/javascript">
Parse.initialize("APPID", "JS KEY");
var TestObject = Parse.Object.extend("CLASSNAME");
var currentDate = new Date();
var testObject = new TestObject();
testObject.set('datefield', currentDate);
testObject.save(null, {
success: function(object) {
$(".success").show();
},
error: function(model, error) {
console.log('error - ', error);
$(".error").show();
}
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With