0

Hi I have trouble have parse date in this format:

1295716379

I don’t what kind of date format is it.

Human readable value of this string is:

22. 1. 2011, 18.12

Also I don’t know that this format is some cowboy coder format or it is some "standard".

And if it is possible parse string on the top to human readable format, for examle in C#, Java, C++.

Thank

1

3 Answers 3

3

It looks like a unix timestamp.

You can parse them like so:

Further links: Epoch Converter.com.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 I agree. And if you want to parse that in C#, see here: stackoverflow.com/questions/1674215/parsing-unix-time-in-c
0

That's a UNIX Epoch timestamp.

An example in C# to convert it to a DateTime:

DateTime ToDateTime(int seconds)
{
    DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    return epoch.ToLocalTime().AddSeconds(seconds);
}

This will convert it into local time.

Comments

0

Verified, it is a unix timestamp.

The time is Sat Jan 22 17:12:59 2011 in UTC.

It looks like you have a local time value and your timezone is UTC+1.

In C/C++:

#define  _USE_32BIT_TIME_T
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main()
{
    int i = atoi("1295716379");
    time_t t = (time_t)i;
    puts(ctime( &t ));
    tm t_tm = *gmtime(&t);
    puts(asctime( &t_tm ));
    return 0;
}

Output:

Sun Jan 23 02:12:59 2011

Sat Jan 22 17:12:59 2011

Note that gmtime return UTC time value, localtime return local time value.

PS: I'm living in UTC+9 timezone

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.