unix-timestamp

How to convert timestamps to dates in Bash?

懵懂的女人 提交于 2019-11-28 13:11:47
问题 I need a shell command or script that converts a Unix timestamp to a date. The input can come either from the first parameter or from stdin, allowing for the following usage patterns: ts2date 1267619929 and echo 1267619929 | ts2date Both commands should output "Wed Mar 3 13:38:49 2010". 回答1: On later versions of common Linux distributions you can use: date -d @1267619929 回答2: date -r <number> works for me on Mac OS X. 回答3: This version is similar to chiborg's answer, but it eliminates the

MySQL - Convert MM/DD/YY to Unix timestamp

走远了吗. 提交于 2019-11-28 12:27:22
Is there an easy (single query) way to do this? I'm reading those values from a column in a table and I think that the column itself is defined as a string (can't be helped, i'm afraid). Use UNIX_TIMESTAMP ; SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19'); Update: SELECT UNIX_TIMESTAMP(CAST(fieldName AS DATE)); SELECT UNIX_TIMESTAMP(STR_TO_DATE('08/05/10','%m/%d/%y')); SELECT '12/31/10', STR_TO_DATE('12/31/10', '%m/%d/%y'), UNIX_TIMESTAMP(STR_TO_DATE('12/31/10', '%m/%d/%y')) Both functions are covered here: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html 来源: https:/

Convert Unix timestamp to Java Date, Spring RequestParam

≡放荡痞女 提交于 2019-11-28 12:21:50
Following is a request fullcalendar js send to the server. http://localhost:8080/NVB/rest/calendar/events?start=1425168000&end=1428796800 400 How to specify Date pattern ( @DateTimeFormat ) in Spring Request Param to convert this time to a Date object. I tried different patterns but getting 405 Bad Request. @RequestMapping(value = "/events", method = RequestMethod.GET) public @ResponseBody List<EventDto> addOrder(@RequestParam(value = "start") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date start, @RequestParam(value = "end") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date end) {

UnixTime to readable date

流过昼夜 提交于 2019-11-28 10:03:31
What is the best way to convert UnixTime to a date? Is there a function for it or an algorithm? Olaf Dietsche Unix time is seconds since epoch (1970-01-01). Depending on what you mean, you can convert it to a struct tm with localtime or convert it to a string with strftime . time_t t = time(NULL); struct tm *tm = localtime(&t); char date[20]; strftime(date, sizeof(date), "%Y-%m-%d", tm); As the manual to localtime states The return value points to a statically allocated struct which might be overwritten by subsequent calls to any of the date and time functions. This is what some refer to as

Ordering WP Posts by Custom Meta Key

末鹿安然 提交于 2019-11-28 07:52:26
问题 I created a WordPress custom post type to be able to create events, select the event's date, and display the date on the frontend. I added a new meta_key in the postmeta of WP's database to store the event's date in a UNIX timestamp. I've had no trouble creating a new WP query to output my events on my site but I am trying to figure out how to organize the events by their UNIX timestamp in the database, not by the date that WordPress created the events. I can't seem to wrap my head around the

Use MySQL to determine whether today is a user's birthday

老子叫甜甜 提交于 2019-11-28 07:43:24
I have all users' birthdays stored as a UNIXtimestamp and am wanting to send out e-mails each day to users that have a birthday that day. I need to make a MySQL query that will get all of the rows that contain a birthday on today's date. It seems like this should be fairly simple, but maybe I am just overcomplicating it. This should work: SELECT * FROM USERS WHERE DATE_FORMAT(FROM_UNIXTIME(birthDate),'%m-%d') = DATE_FORMAT(NOW(),'%m-%d') Here is an answer that property takes into account leap-years and will always give you the users whose birthday is on the 29th of February at the same time as

How should unix timestamps be stored in int columns?

我怕爱的太早我们不能终老 提交于 2019-11-28 04:37:39
I have a logging table that will contain millions of writes for statistical reasons. All the columns are int foreign keys. I am also going to add a timestamp column for each row. Given that DATETIME takes 8bits - I will be using int(10) unsigned to cut the storage space (and index on that column) in half. However, I'm wondering when this column would no longer work. At 3:14:07AM on 19th January 2038 the value 9,999,999,999 will be a problem for UNIX timestamps - but an unsigned int in MySQL only holds up to 4,294,967,295 and the timestamp 4294967295 is showing an invalid number in my PHP

Ticks between Unix epoch and GPS epoch

匆匆过客 提交于 2019-11-28 04:33:08
What is the number of one second ticks between Unix time epoch (01 Jan 1970) and GPS time epoch (06 Jan 1980)? I have seen multiple answers from several sources on the web. One camp claims the answer is 315964800 , the other claims it is 315964819 . I always thought it was 315964800, but now am not so sure. I just found my software baseline has been using 315964819 for the last eight years. I have a hard time understanding how it could have been 19 seconds off and no one noticed it when we integrated our embedded devices with other devices. I think that whoever put 315964819 in the code

UNIX timestamp(0): Europe/London returns UTC+1

时光怂恿深爱的人放手 提交于 2019-11-28 04:28:21
问题 Learning dates and they're giving me hard time right now. $london = new DateTime(); $london->setTimestamp(0); $london->setTimeZone(new DateTimeZone('Europe/London')); echo $london ->format('d-m-Y H-i-s'); result: 01-01-1970 01-00-00 Shouldn't be London in UTC +0:00 therefore midnight? For example, New York returns 19:00 of the previous date which is correctly UTC -5:00 . Moscow returns 01-01-1970 03-00-00 which is again incorrect ( UTC +3:00 as opposed to UTC +4:00 ) When not using -

How to create human readable time stamp?

感情迁移 提交于 2019-11-28 03:07:11
问题 This is my current PHP program: $dateStamp = $_SERVER['REQUEST_TIME']; which I later log. The result is that the $dateStamp variable contains numbers like: 1385615749 This is a Unix timestamp, but I want it to contain human readable date with hour, minutes, seconds, date, months, and years. So I need a function that will convert it into a human readable date. How would I do that? There are other similar questions but not quite like this. I want the simplest possible solution. 回答1: This number