Since it seems you are asking for C++, I add this answer. Comments try to explain issues about the fact that your input value won't fit into a 32bit variable, and if you can't have a 64bit variable, you need to "divide" before, by removing last three chars as duskwuff answer suggests.
#include <sstream>
#include <iostream>
#include <cstring>
#include <ctime>
// uint64_t ... gcc complains it's a C++11 stuff
//#include <cinttypes>
int main()
{
const char *d = "1380994682285";
std::stringstream is(d);
// ISO C++98 does not support long long
// ... it should be uint64_t, but supported in C++11...
// or rather, just long but be sure you compile for 64bit
std::cout << sizeof (long) << "\n"; // very likely 4 on 32bit
std::cout << sizeof (long long) << "\n"; // 8
unsigned long long epoch64;
// if you need strict ISO C++98 conformance, you must use unsigned long,
// see below.
is >> epoch64;
std::cout << epoch64 << "\n";
epoch64 /= 1000;
// this goes ok (if epoch64 is big enough), since /1000 makes it
// small enough to go into time_t
time_t t = epoch64;
std::cout << std::ctime(&t) << "\n";
// if you use unsigned long for epoch, and it turns out to
// be sizeof (unsigned long) == 4, then you get the wrong output.
// Then, you must make it shorter before to convert it:
std::string shorter(d, strlen(d)-3); // assert(strlen(d)>3)
std::stringstream is2(shorter);
unsigned long epoch32; // I am on a 32bit machine
is2 >> epoch32;
t = epoch32;
std::cout << epoch32 << "\n";
std::cout << std::ctime(&t) << "\n";
return 0;
}
This answers does not handle errors, e.g. the case when streaming is not able to read an integer, e.g. when you have "a string" instead of "1234".