unix-timestamp

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

MySQL: What's the best to use, Unix TimeStamp Or DATETIME [duplicate]

蓝咒 提交于 2019-11-28 20:20:17
This question already has an answer here: Should I use the datetime or timestamp data type in MySQL? 36 answers Probably many coders want to ask this question. it is What's the adventages of each one of those MySQL time formats. and which one you will prefer to use it in your apps. For me i use Unix timestamp because maybe i find it easy to convert & order records with it, and also because i never tried the DATETIME thing. but anyways i'm ready to change my mind if anyone tells me i'm wrong. Thanks Timestamp (both PHP ones and MySQL's ones) are stored using 32 bits (i.e. 4 bytes) integers ;

Converting unix time into date-time via excel

谁说我不能喝 提交于 2019-11-28 20:20:07
Trying to convert 1504865618099.00 Unix time into a readable date time. I tried this: =(UNIX + ("1/1/1970"-"1/1/1900"+1)*86400) / 86400 But it's not working. To convert the epoch(Unix-Time) to regular time like for the below timestamp Ex: 1517577336206 First convert the value with the following function like below =LEFT(A1,10) & "." & RIGHT(A1,3) The output will be like below Ex: 1517577336.206 Now Add the formula like below =(((B1/60)/60)/24)+DATE(1970,1,1) Now format the cell like below or required format(Custom format) m/d/yyyy h:mm:ss.000 Now example time comes like 2/2/2018 13:15:36.206

Date string conversion to unix timestamp in JavaScript / jQuery

六月ゝ 毕业季﹏ 提交于 2019-11-28 18:37:23
I have date string in this format: 2009-07-15 00:00:00 - 2009-07-15 08:16:23 Could anyone help me to tweak the date string to unix timestamp into something like this: 1247634000 - 1247663783 I am using GMT-5 Timezone. What JavaScript or jQuery techniques could be used? var input = "2009-07-15 00:00:00 - 2009-07-15 08:16:23"; input = input.split(" - ").map(function (date){ return Date.parse(date+"-0500")/1000; }).join(" - "); Demo Date.parse docs Note: This won't work on old browsers since I'm using Array.map , but I think you should easily be able to shim it. Grzegorz Kaczan I strongly advise

Go / golang time.Now().UnixNano() convert to milliseconds?

邮差的信 提交于 2019-11-28 16:57:16
How can I get Unix time in Go in milliseconds? I have the following function: func makeTimestamp() int64 { return time.Now().UnixNano() % 1e6 / 1e3 } I need less precision and only want milliseconds. OneOfOne Just divide it: func makeTimestamp() int64 { return time.Now().UnixNano() / int64(time.Millisecond) } Here is an example that you can compile and run to see the output package main import ( "time" "fmt" ) func main() { a := makeTimestamp() fmt.Printf("%d \n", a) } func makeTimestamp() int64 { return time.Now().UnixNano() / int64(time.Millisecond) } As @Jono points out in @OneOfOne's

How can I generate Unix timestamps?

只谈情不闲聊 提交于 2019-11-28 15:15:23
Related question is "Datetime To Unix timestamp" , but this question is more general. I need Unix timestamps to solve my last question. My interests are Python, Ruby and Haskell, but other approaches are welcome. What is the easiest way to generate Unix timestamps? Naresh In Linux or MacOS you can use: date +%s where +%s , seconds since 1970-01-01 00:00:00 UTC. (GNU Coreutils 8.24 Date manual) Example output now 1454000043. in Ruby: >> Time.now.to_i => 1248933648 Steven Kryskalla In python add the following lines to get a time stamp: >>> import time >>> time.time() 1335906993.995389 >>> int

Converting Unix time stamp to dd/mm/yyyy hh:mm:ss

蹲街弑〆低调 提交于 2019-11-28 14:35:29
I have a column that holds Unix timestamps at C1, and I am looking for the formula to create a new column that converts the timestamp to dd/mm/yyyy hh:mm:ss. Here is a sample of the timestamp: 1409502202 You are going to have to provide some conversion from the UNIX (aka POSIX) timestamp to an Excel Date format. Typically this is performed by dividing the timestamp by 86,400 (number of seconds in a day) and adding 25,569 (number of days from 01-Jan-1900 to 01-Jan-1970). With a raw value that is in synch with the Excel date/time numerical system, the TEXT function can create the date/time.

Why does strtotime give different result in different timezone?

被刻印的时光 ゝ 提交于 2019-11-28 13:52:14
I am not sure why strtotime() in PHP returns different result in different timezone even though same date is given as parameter, does anyone know the answer? I also want to know, can I do similar task (converting a datetime to an int to do calculations easily) with another function which gives same result across different timezone? EDIT: An example: If I use strtotime('2011-09-19 00:00:00') shouldn't it just return the difference between 'January 1 1970 00:00:00' and '2011-09-19 00:00:00' in seconds ? Why timezone is an issue here? And can I get something which gives just difference without

Get current NSDate in timestamp format

六月ゝ 毕业季﹏ 提交于 2019-11-28 13:49:42
问题 I have a basic method which gets the current time and sets it in a string. However, how can I get it to format the current date & time in a UNIX since-1970 timestamp format? Here is my code: NSDate *currentTime = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"hh-mm"]; NSString *resultString = [dateFormatter stringFromDate: currentTime]; Is it possible to use NSDateFormatter to change the 'resultString' into a timestamp? 回答1: Here

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