epoch

Nginx 操作响应头信息的实现

十年热恋 提交于 2019-11-27 08:37:20
前置条件:需要编译 ngx_http_headers_module 模块,才支持 header 头信息操作 add_header 意思为将自定义的头信息的添加到响应头,指令为 add_header name value [always];,可以用在 http {}, server {}, location {}, if in location {} 上下文中, 只有当响应状态码等于 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), 或 308 (1.13.0) 时生效,如果 always 参数指定了,头信息将无视状态码,在所有响应中强制返回。 注意: 可以声明多个 add_header 指令,当且仅当 当前区块没有 add_header 的时候,才会继承上级声明的 add_header 信息 例如: server { add_header a 123; location / { root /path; } location /download/ { add_header b 321; } } 如上的例子,在访问 /download/ 路由的时候,将返回 b 321 这样的头信息,而访问 / 路由时,将返回上级指定的 a 123 头信息。 add_trailer

Convert unix epoch timestamp to TSQL datetime

风格不统一 提交于 2019-11-27 07:51:46
问题 I have found only one similar question but for MySQL. I was working on a web service and had to query the database (MS SQL server). Since I couldn't get the right result I decided to test the query via a SQL client. The web service uses Hibernate to access the DB and all time values are always represented as long values (unix epoch time). In order to test it, I needed to convert the unix timestamp to TSQL timestamp. This is what I came up with: select dateadd(ms,123,'1970-01-01 00:00:00.0');

How to extract epoch from LocalDate and LocalDateTime?

梦想与她 提交于 2019-11-27 07:31:28
How do I extract the epoch value to Long from instances of LocalDateTime or LocalDate ? I've tried the following, but it gives me other results: LocalDateTime time = LocalDateTime.parse("04.02.2014 19:51:01", DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")); System.out.println(time.getLong(ChronoField.SECOND_OF_DAY)); // gives 71461 System.out.println(time.getLong(ChronoField.EPOCH_DAY)); // gives 16105 What I want is simply the value 1391539861 for the local datetime "04.02.2014 19:51:01" . My timezone is Europe/Oslo UTC+1 with daylight saving time. The classes LocalDate and LocalDateTime

Convert epoch to Date via XSL from XML attribute and display in HTML

房东的猫 提交于 2019-11-27 07:19:41
问题 First time posting and am very new to working with XML and XSL. I've spent two days on this board and others looking for my answer. I see posts similar to mine, but not exact. My apologies if this is redundant. I have an XML document output to me from a 3rd party application on a daily basis. I need to display on a webpage two pieces of information from it: LoginName and LastBackupDate . I am able to do this via an XSL that I wrote. However, the LastBackupDate is in epoch format. I need to

Java time since the epoch

最后都变了- 提交于 2019-11-27 06:39:18
问题 In Java, how can I print out the time since the epoch given in seconds and nanoseconds in the following format : java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); My input is: long mnSeconds; long mnNanoseconds; Where the total of the two is the elapsed time since the epoch 1970-01-01 00:00:00.0 . 回答1: You can do this public static String format(long mnSeconds, long mnNanoseconds) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); return sdf.format(new Date(mnSeconds

Converting epoch time to “real” date/time

时光总嘲笑我的痴心妄想 提交于 2019-11-27 04:46:55
What I want to do is convert an epoch time (seconds since midnight 1/1/1970) to "real" time (m/d/y h:m:s) So far, I have the following algorithm, which to me feels a bit ugly: void DateTime::splitTicks(time_t time) { seconds = time % 60; time /= 60; minutes = time % 60; time /= 60; hours = time % 24; time /= 24; year = DateTime::reduceDaysToYear(time); month = DateTime::reduceDaysToMonths(time,year); day = int(time); } int DateTime::reduceDaysToYear(time_t &days) { int year; for (year=1970;days>daysInYear(year);year++) { days -= daysInYear(year); } return year; } int DateTime:

Convert Unix time with PowerShell

妖精的绣舞 提交于 2019-11-27 02:10:01
I am parsing an SQLite database using the PowerShell SQLite module, and a couple of the return values are created and modified, both of which are in Unix time. What I would like to do is somehow convert that into "human time". I have removed some of the other SQL queries for ease of reading. Import-Module SQLite mount-sqlite -name GoogleDrive -dataSource E:\Programming\new.db $cloud_entry = Get-ChildItem GoogleDrive:\cloud_entry foreach ($entry in $cloud_entry) { $entry.created } The output looks like a large column of Unix timestamps: 1337329458 Update : I ultimately went with the following:

How to convert a string Date to long millseconds

假如想象 提交于 2019-11-27 01:54:53
I have a date inside a string, something like "12-December-2012". How can I convert this into milliseconds (long)? Jon Lin Using SimpleDateFormat String string_date = "12-December-2012"; SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy"); try { Date d = f.parse(string_date); long milliseconds = d.getTime(); } catch (ParseException e) { e.printStackTrace(); } SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); Date date = (Date)formatter.parse("12-December-2012"); long mills = date.getTime(); Take a look to SimpleDateFormat class that can parse a String and return a Date and

How do I get epoch time in C#? [duplicate]

强颜欢笑 提交于 2019-11-27 01:43:18
问题 Possible Duplicate: How do you convert epoch time in C#? I'm trying to figure out how to get the epoch time in C#. Similar to the timestamps given on this website: http://www.epochconverter.com/ Does DateTime have a method for that? 回答1: TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); int secondsSinceEpoch = (int)t.TotalSeconds; Console.WriteLine(secondsSinceEpoch); 来源: https://stackoverflow.com/questions/9453101/how-do-i-get-epoch-time-in-c

jquery convert number to date? [duplicate]

青春壹個敷衍的年華 提交于 2019-11-27 01:30:52
问题 This question already has an answer here: Convert UTC Epoch to local date 15 answers i have a json file that returns "date_created":"1273185387" in epoch format i want to convert it to something like this Thu, 06 May 2010 22:36:27 GMT any script to do this conversion? 回答1: var myObj = $.parseJSON('{"date_created":"1273185387"}'), myDate = new Date(1000*myObj.date_created); console.log(myDate.toString()); console.log(myDate.toLocaleString()); console.log(myDate.toUTCString()); http://jsfiddle