epoch

Converting TIMESTAMP to unix time in PHP?

ぃ、小莉子 提交于 2019-11-28 22:54:40
Currently I store the time in my database like so: 2010-05-17 19:13:37 However, I need to compare two times, and I feel it would be easier to do if it were a unix timestamp such as 1274119041 . (These two times are different) So how could I convert the timestamp to unix timestamp? Is there a simple php function for it? You're looking for strtotime() You want strtotime : print strtotime('2010-05-17 19:13:37'); // => 1274123617 Getting a unixtimestamp: $unixTimestamp = time(); Converting to mysql datetime format: $mysqlTimestamp = date("Y-m-d H:i:s", $unixTimestamp); Getting some mysql timestamp

Elasticsearch数据类型及其属性

走远了吗. 提交于 2019-11-28 22:12:23
一、数据类型 字段类型概述 一级分类 二级分类 具体类型 核心类型 字符串类型 string,text,keyword h 整数类型 integer,long,short,byte h 浮点类型 double,float,half_float,scaled_float h 逻辑类型 boolean h 日期类型 date h 范围类型 range h 二进制类型 binary 复合类型 数组类型 array f 对象类型 object f 嵌套类型 nested 地理类型 地理坐标类型 geo_point d 地理地图 geo_shape 特殊类型 IP类型 ip t 范围类型 completion t 令牌计数类型 token_count t 附件类型 attachment t 抽取类型 percolator 核心类型 1、字符串类型   string类型: 在ElasticSearch 旧版本中使用较多,从ElasticSearch 5.x开始不再支持string,由text和keyword类型替代。   text 类型:当一个字段是要被全文搜索的,比如Email内容、产品描述,应该使用text类型。设置text类型以后,字段内容会被分析,在生成倒排索引以前,字符串会被分析器分成一个一个词项。text类型的字段不用于排序,很少用于聚合。   keyword

Convert a NSDate to milliseconds epoch time

此生再无相见时 提交于 2019-11-28 21:17:58
I need to be able to convert a date to a time stamp, an epoch in milliseconds. All I see online are for converting milliseconds to NSDate and not the other way round. Any help out there? NSTimeInterval is a double that already contains sub-second data after the decimal point. Depending what you need, your conversion could be a simple as multiplying by 1000. - (void)testDateFormat { NSDate *date = [NSDate date]; NSLog(@"Time: %f", floor([date timeIntervalSince1970] * 1000)); NSLog(@"Time: %f", floor([date timeIntervalSince1970])); NSLog(@"Time: %lli", [@(floor([date timeIntervalSince1970] *

zk中使用zab协议来保证数据一致性

天大地大妈咪最大 提交于 2019-11-28 17:15:48
1zab能够保证一个全局的变更序列被顺序应用 2zab协议包含两个模式: 崩溃恢复 消息广播 Zab协议必须设计这样一个选举算法:能够确保提交已经被leader提交的事务proposal,同时丢弃被跳过的事务Proposal 数据同步 所有运行服务器,要不成为leader,要不成为follower和leader进行同步 在zab协议的事务编号zxid,是一个64位数字,低32位是一个简单的单调递增计数器,高32位是代表leader周期epoch的编号 zab系统模型 进程组,状态有up状态,也有down状态,当集群中存在过半up状态组成的进行后,就可以进行正常的消息广播了 使用pi,pj分别表示进程组[]中两个不同进程,使用cij表示进程pi和pj之间的网络通信通道,满足如下两个基本条件 完整性 如何进程pj收到了来自pi的消息m,那么进程pi一定确实发送了消息m 前置性, 如果进程pj收到了消息m,那么存在这样的消息m`,如果m`是m的前置消息,那么pj务必先接收到消息m`,然后再接收到m,这样才能保证消息的顺序 主进程周期 为了保证每次广播出来的消息是一致的,必须确保zab协议只有在充分完成崩溃恢复阶段之后,新的主进程才可以开始生成新的事务消息广播。 事务, 各个进程都存在一个类似于transactions(v,z)这样的函数调用,来实现主进程对状态变更的广播,v表示事务内容

PostgreSQL: how to convert from Unix epoch to date?

别等时光非礼了梦想. 提交于 2019-11-28 16:59:46
The statement gives me the date and time. How could I modify the statement so that it returns only the date (and not the time)? SELECT to_timestamp( TRUNC( CAST( epoch_ms AS bigint ) / 1000 ) ); /* Current time */ select now(); /* Epoch from current time; Epoch is number of seconds since 1970-01-01 00:00:00+00 */ select extract(epoch from now()); /* Get back time from epoch */ -- Option 1 - use to_timestamp function select to_timestamp( extract(epoch from now())); -- Option 2 - add seconds to 'epoch' select timestamp with time zone 'epoch' + extract(epoch from now()) * interval '1 second'; /*

What is the JavaScript Date.now() time format called?

自古美人都是妖i 提交于 2019-11-28 13:58:43
I'm asking to know what to write in my documentation. MDN describes it as: A Number representing the milliseconds elapsed since the UNIX epoch. While W3Schools describes it as: the number of milliseconds since 1970/01/01 However, those are just descriptions . The Wikipedia page of Unix time states: Unix time is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970 [...] Seconds. Not milliseconds , as returned by Date.now() . So I can't really call it the "unix time format" as well.

Convert unix epoch timestamp to TSQL datetime

老子叫甜甜 提交于 2019-11-28 13:46:30
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'); which outputs: 1970-01-01 00:00:00.123 But, my actual data was a bit bigger select dateadd(ms

Redis哨兵(Sentinel)模式快速入门

拜拜、爱过 提交于 2019-11-28 13:14:21
更多内容,欢迎关注微信公众号:全菜工程师小辉。公众号回复关键词,领取免费学习资料。 当主服务器宕机后,需要手动把一台从服务器切换为主服务器,这就需要人工干预,费事费力,还会造成一段时间内服务不可用。 所以更多时候,我们优先考虑哨兵(sentinel) 模式。 Redis sentinel是Redis高可用实现方案:故障发现、故障自动转移、配置中心、客户端通知。从Redis的2.6版本开始提供的,但是当时这个版本的模式是不稳定的,直到Redis的2.8版本以后,这个哨兵模式才稳定下来,在生产环境中,如果想要使用Redis的哨兵模式,也会尽量使用Redis的2.8版本之后的版本。 哨兵虽然有一个单独的可执行文件Redis-sentinel ,但实际上它只是一个运行在特殊模式下的 Redis服务器,你可以在启动一个普通Redis服务器时通过给定 --sentinel 选项来启动哨兵,哨兵的一些设计思路和zookeeper非常类似。 sentinel的定时任务 sentinel机制中有三种重要的定时任务。 每10秒每个sentinel对master和slave执行info 作用: 发现slave节点。 确认主从关系。 每2秒每个sentinel通过master节点的channel交换信息(pub/sub) 作用: 互相通信掌握节点的信息和自身信息,可以感知新加入的sentinel >

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

烈酒焚心 提交于 2019-11-28 12:55:58
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 convert it to human readable Date/Time (mm-dd-yyyy hh:mm:ss). Is it possible to convert this "on the fly"

Java time since the epoch

纵然是瞬间 提交于 2019-11-28 11:59:24
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 . 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*1000)) + String.format("%09d", mnNanoseconds); } e.g. 2012-08-08 19:52:21.123456789 if you don't really need