unix-timestamp

How to write an SQL query that counts the number of rows per month and year?

不想你离开。 提交于 2019-12-06 04:47:23
问题 Had anyone any idea how to query a vbulletin database to generate a report on the number of registrations per month/year to achive results like.. MM/YYYY Count 01/2001 : 10 02/2001 : 12 ... ... Thanks to those answers below.. My final version that works is as follows: SELECT COUNT(*) as 'Registrations', YEAR(FROM_UNIXTIME(joindate)) as 'Year', MONTH(FROM_UNIXTIME(joindate)) as 'Month' FROM vbfuser GROUP BY Year,Month 回答1: I am not familiar with vBulletin's database structure, but you should

Convert string time to UNIX timestamp

寵の児 提交于 2019-12-05 23:35:52
问题 I have a string like 2013-05-29T21:19:48Z . I'd like to convert it to the number of seconds since 1 January 1970 (the UNIX epoch), so that I can save it using just 4 bytes (or maybe 5 bytes, to avoid the year 2038 problem). How can I do that in a portable way? (My code has to run both on Linux and Windows.) I can get the date parts out of the string, but I don't know how to figure out the number of seconds. I tried looking at the documentation of date and time utilities in C++, but I didn't

how convert unix timestamp to datetime

回眸只為那壹抹淺笑 提交于 2019-12-05 12:39:49
I'm trying to convert this unix timestamp 1415115303410 in DateTime, in this way: private static DateTime UnixTimeStampToDateTime(long unixTimeStamp) { System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp); return dtDateTime; } But I get a wrong date: Date: {04/11/0045 00:00:00} NOTE: dtDateTime.AddSeconds(unixTimeStamp) throws an exception.. my number is in Milliseconds. with this online conversion tool http://www.epochconverter.com/ I get the right conversion: 04/11/2014 15:35:03 GMT+0:00 How I can

AngularJS UnixTime to DateTime Format with date filter failed

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:58:10
问题 I learned that one can transform a unix time stamp into a date by using date filter from this post: AngularJS. Convert tag value (Unix time to human-readable time) But I can not convert mine with it... <td>{{contract.start_date_unix | date:'MM-dd-yyyy'}}</td> inside the contract.start_date_unix , its valued at 1406779200 I checked it with a checker that it shows exactly what I want: Thu, 31 Jul 2014 04:00:00 GMT (but of course, the format I want is MM-dd-yyyy, the date is correct and that's

MongoDb timestamp

倖福魔咒の 提交于 2019-12-05 05:11:49
i have created and want to now import a dummy collection. one of the fields in each item are "created" and "updated" fields. what can i put in the source/json file so that MongoDb will use the current date and time as the value on import? this wont work "created" : Date() mongoimport is intended for importing data existing data in CSV, TSV, or JSON format. If you want to insert new fields (such as a created timestamp) you will have to set a value for them. For example, if you want to set the created timestamp to the current time, you could get a unix timestamp from the command line (which will

MySQL convert datetime to unixtime?

£可爱£侵袭症+ 提交于 2019-12-05 03:26:15
I have a column with the DATETIME format and I would like to convert it to UNIXTIME in the database. What kind of query would that be? I know how to convert from UNIXTIME to DATETIME, but I've never done the reverse. I've used FROM_UNIXTIME, is there no TO_UNIXTIME? It's UNIX_TIMESTAMP . This will take a properly formatted datetime as an argument. It's okay, I figured it out. I had 'article_date' for the original column. I created 'new_date' for the new column. Then I did: UPDATE news SET new_date = UNIX_TIMESTAMP(article_date) 来源: https://stackoverflow.com/questions/18494493/mysql-convert

MSSQL bigint Unix Timestamp to Datetime with milliseconds

冷暖自知 提交于 2019-12-05 02:38:26
问题 I have some timestamps that are in bigint. Here's one: 1462924862735870900 This is down to microsecond precision. I am currently using this: SELECT DATEADD(S, CONVERT(int,LEFT(1462924862735870900, 10)), '1970-01-01') That's giving me datetime down to the second but I would like to maintain at least millisecond precision. I realize that DATEADD cannot handle bigint that's why I truncated the bigint and converted it to int. If I don't do that I get this error: Arithmetic overflow error

How to decompose unix time in C

冷暖自知 提交于 2019-12-05 02:30:41
问题 This seems like something no one should ever have to do, but I'm working on a kernel module for an embedded system (OpenWRT) in which it seems that time.h does include the timespec and time_t types, and the clock_gettime and gmtime functions, but does not include localtime , ctime , time , or, critically, the tm type. When I attempt to cast the return pointer from gmtime to my own struct, I get a segfault. So I guess I'd be content to solve the problem either of two ways—it'd be great to

android timestamp parsing gone wrong(always in 1970)

偶尔善良 提交于 2019-12-05 01:57:42
问题 im trying to convert a string(with unix timestamp) to an date with the format ( dd-MM-yyyy) and this is working partly. The problem im having now is that my date is in 17-01-1970 (instead of march 16 2015) im converting it like this: SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); Date d = null; int dateMulti = Integer.parseInt(Date); Calendar cal = Calendar.getInstance(Locale.ENGLISH); cal.setTimeInMillis(dateMulti); String date = DateFormat.format("dd-MM-yyyy", cal)

How can I display a formatted date from a Unix timestamp in twig?

限于喜欢 提交于 2019-12-04 22:52:00
I would like to display a formatted date in twig by applying a filter to a Unix timestamp. Is such a feature available in twig? There is a filter called date . In the following example mydate equals 1286199900 : {{ mydate|date }} <!-- October 4, 2010 13:45 --> {{ mydate|date('d/m/Y') }} <!-- 04/10/2010 --> If you just divide it by 1000 there might be an error like Failed to parse time string (1384361503.5) at position 7 I would add round function to it {% set timestamp = (rating.ratingDate / 1000)|round(0, 'floor') %} {{timestamp|date('d. M Y')}} I know I am playing an archaeologist but it