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

3 Answers3

3

It looks like a unix timestamp.

You can parse them like so:

Further links: Epoch Converter.com.

Community
  • 1
  • 1
Sebastian Paaske Tørholm
  • 49,493
  • 11
  • 100
  • 118
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.

Joshua Rodgers
  • 5,317
  • 2
  • 31
  • 29
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

9dan
  • 4,222
  • 2
  • 29
  • 44