How to get 'real' time?

I need to get the current time in good ole 'seconds since 1970' format. Using JScript.

I tried the System call DateTime.Now and DateTime.UtcNow, but I get this error:

BCE0077: It is not possible to invoke an expression of type 'Date'.

Any ideas?

The code fragment presented here did not give me the correct time compared to for example the Java unix time. I do get the right time however with the example in this post:

The main difference is that the 8 is zero, I assume that the 8 a typo?

var epochStart = new System.DateTime(1970, 1, 1, ->0<-, 0, 0,System.DateTimeKind.Utc);
var timestamp = (System.DateTime.UtcNow - epochStart).TotalSeconds;

Actually I needed ‘unix’ time in UTC. This is what I ended up with:

var epochStart = new System.DateTime(1970, 1, 1, 8, 0, 0, System.DateTimeKind.Utc);
var timestamp = (System.DateTime.UtcNow - epochStart).TotalSeconds;

They are implemented as properties, not methods. Did you by chance include parenthesis in your call?

var dt = DateTime.Now();  // wrong
var dt = DateTime.Now;

just to provide a complementary answer, on js would be like:

var dt = Date();

var day = dt.Now.Day.ToString();

var month = dt.Now.Month.ToString();

var year = dt.Now.Year.ToString();

var hours = dt.Now.Hour.ToString();

var minutes = dt.Now.Minute.ToString();

if (parseInt(minutes) < 10) minutes = “0” + minutes;

var seconds = dt.Now.Second.ToString();

if(parseInt(seconds) < 10) seconds = “0” + seconds;

Like Bampf said, you don’t access them as methods, only as properties on unityscript. Also calling new Date() gives you a zeroed date, so you need to use .Now to get the current time.