Sectah Sectah - 12 days ago 7
MySQL Question

Store SDateTime in SQL database using Haxe

I'm currently using Haxe to create a database and table for storing game data.

I have a field that will be a timestamp. I'm using the following:

class GameData extends Object {
public var id : SId;
public var username : SString<32>;
public var countryA2 : SString<32>;
public var scoreFor : SInt;
public var scoreAgainst : SInt;
public var scoreDifference : SInt;
public var ts : SDateTime;
}


I'm then trying to populate this field by using

gameData.ts = Date.now();


But all this returns is "Date" and not an actual date in numbers.

I then tried the DateTools.format() class and produced this:

DateTools.format(Date.now(), "%Y-%m-%d %H:%M:%S")


Which gave me the date/time as follows: 2016-11-25 19:17:13

But then trying to store this in the field just returns an error:

String should be sys.db.SDateTime


What's the ideal way of storing date/time in an SQL database through Haxe?

Thanks.

Answer

Managed to resolve it now, fresh day seemed to strangely allow Date.now() to work. Thanks for the help guys.