Convert normal date to unix timestamp
Math.floor(new Date(‘2012.08.10’).getTime() / 1000) Check the JavaScript Date documentation.
Math.floor(new Date(‘2012.08.10’).getTime() / 1000) Check the JavaScript Date documentation.
These appear to be seconds since epoch. In [20]: df = DataFrame(data[‘values’]) In [21]: df.columns = [“date”,”price”] In [22]: df Out[22]: <class ‘pandas.core.frame.DataFrame’> Int64Index: 358 entries, 0 to 357 Data columns (total 2 columns): date 358 non-null values price 358 non-null values dtypes: float64(1), int64(1) In [23]: df.head() Out[23]: date price 0 1349720105 12.08 1 … Read more
Yes. ‘Z’ stands for Zulu time, which is also GMT and UTC. From http://en.wikipedia.org/wiki/Coordinated_Universal_Time: The UTC time zone is sometimes denoted by the letter Z—a reference to the equivalent nautical time zone (GMT), which has been denoted by a Z since about 1950. The letter also refers to the “zone description” of zero hours, which … Read more
The time.Parse function does not do Unix timestamps. Instead you can use strconv.ParseInt to parse the string to int64 and create the timestamp with time.Unix: package main import ( “fmt” “time” “strconv” ) func main() { i, err := strconv.ParseInt(“1405544146”, 10, 64) if err != nil { panic(err) } tm := time.Unix(i, 0) fmt.Println(tm) } … Read more
The definition of UNIX timestamp is time zone independent. The UNIX timestamp is the number of seconds (or milliseconds) elapsed since an absolute point in time, midnight of Jan 1 1970 in UTC time. (UTC is Greenwich Mean Time without Daylight Savings time adjustments.) Regardless of your time zone, the UNIX timestamp represents a moment … Read more
Try gmdate like this: <?php $timestamp=1333699439; echo gmdate(“Y-m-d\TH:i:s\Z”, $timestamp); ?>
Use FROM_UNIXTIME(): SELECT FROM_UNIXTIME(timestamp) FROM your_table; See also: MySQL documentation on FROM_UNIXTIME().
Avoid the Date object creation w/ System.currentTimeMillis(). A divide by 1000 gets you to Unix epoch. As mentioned in a comment, you typically want a primitive long (lower-case-l long) not a boxed object long (capital-L Long) for the unixTime variable’s type. long unixTime = System.currentTimeMillis() / 1000L;
Another way is to use calendar.timegm: future = datetime.datetime.utcnow() + datetime.timedelta(minutes=5) return calendar.timegm(future.timetuple()) It’s also more portable than %s flag to strftime (which doesn’t work on Windows).
I would use time.time() to get a timestamp in seconds since the epoch. import time time.time() Output: 1369550494.884832 For the standard CPython implementation on most platforms this will return a UTC value.