unix-timestamp

How to create human readable time stamp?

守給你的承諾、 提交于 2019-11-29 09:46:41
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. Havenard This number is called Unix time . Functions like date() can accept it as the optional second parameter to

convert date to unixtime php

醉酒当歌 提交于 2019-11-29 09:23:46
I have a form which posts date information month, day, yeah, hour, minute, am/pm. How do i encode/decode this to and from unixtime using php? mktime() - Get Unix timestamp for a date echo mktime(23, 24, 0, 11, 3, 2009); 1257290640 To handle AM/PM just add 12 to hours if PM. mktime($isAM ? $hrs : ($hrs + 12), $mins, $secs, $m, $d, $y); Alternatively you could use strtotime(): strtotime() - Parse about any English textual datetime description into a Unix timestamp echo strtotime("2009-11-03 11:24:00PM"); 1257290640 Use the mktime function 来源: https://stackoverflow.com/questions/1670797/convert

How to convert a 13 digit Unix Timestamp to Date and time?

怎甘沉沦 提交于 2019-11-29 09:21:28
I have this 13 digit timestamp 1443852054000 that i want to convert to date and time but dont succeed. I have tried this codes: echo date('Y-m-d h:i:s',$item->timestamp); doesnt work for me and also this $unix_time = date('Ymdhis', strtotime($datetime )); and this : $item = strtotime($txn_row['appoint_date']); <?php echo date("Y-m-d H:i:s", $time); ?> what should i use? u_mulder This timestamp is in milliseconds, not in seconds. Divide it by 1000 and use date function: echo date('Y-m-d h:i:s', $item->timestamp / 1000); // e.g echo date('Y-m-d h:i:s',1443852054000/1000); // shows 2015-10-03 02

selecting rows in the last 5 minutes using unix time stamp

空扰寡人 提交于 2019-11-29 05:08:24
Iam trying to figure out whetere data was save to the db in the las 5 minutes. SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') FROM `table` WHERE `timestamp` >= CURRENT_TIMESTAMP - INTERVAL 5 MINUTE timestamp is a unix timestamp (millisecs from 1970). doesn't work, I get null num_rows instead of 0 and if I use if (!isset($resultHistory->num_rows) || !$resultHistory->num_rows) to do actions, the code does not enter the loop.. I also tried SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') FROM `table` WHERE DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') >= CURRENT_TIMESTAMP -

Batch: Timestamp to UNIX Time

半世苍凉 提交于 2019-11-29 03:54:40
For all I know, Batch does not have a command that gives the UNIX time. The closest one I can find is %time% , which only displays the timestamp. Is there a command, or set of commands in Batch with which you can get the UNIX time? There's Richie Lawrence's batch library that has all those nifty handy scripts. The one you need is DateToSec (which uses GetDate and GetTime ). Here's a simplified script, that employs a little WMI : @echo off setlocal call :GetUnixTime UNIX_TIME echo %UNIX_TIME% seconds have elapsed since 1970-01-01 00:00:00 goto :EOF :GetUnixTime setlocal enableextensions for /f

Difference between UNIX_TIMESTAMP and NOW() in MySQL

☆樱花仙子☆ 提交于 2019-11-29 03:42:14
问题 I have a blog where users can comment. I insert the time at which they posted a comment using NOW() and then use date('j M Y', stored timestamp) to show the time at which they posted. I want to know does NOW() return the locatime of the end user or the localtime at my server . Is it better suited to use UNIX_TIMESTAMP than NOW() to calculate the localtime at which users posted a comment. 回答1: The function NOW() generates a formatted date-time string, determined by the time zone of your MySQL

unix timestamp round to midnight

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 03:02:54
If I have a random unix timestamp, how can I round it down to today's midnight or the midnight selected by the user. The reason for this is that I want to add hours and minutes after a certain day's midnight. For example if the timestamp is 1324189035 then how can I remove the hours, minutes, and seconds to put the timestamp at midnight for that day. echo date('d-m-Y H:i:s', strtotime('today', 1324189035)); Because of how you're using it, I wouldn't calculate midnight at all: it is far easier to simply convert what you're adding to the timestamp into 24 hour time and then use strtotime: echo

When does a UNIX directory change its timestamp

懵懂的女人 提交于 2019-11-29 02:06:22
问题 I used "touch" on a file, updating the file's timestamp but the parent directory's timestamp did not change. However, (as expected) when I created a new file within the parent directory, the directory's timestamp did change. What criteria do UNIX-like operating systems (specifically AIX) use to determine when to update the timestamp of a directory? 回答1: The timestamp is updated when the data that represents the directory changes. A change in a subdirectory of directory D does not change

How to convert strings like “19-FEB-12” to epoch date in UNIX

大憨熊 提交于 2019-11-29 01:09:06
In UNIX how to convert to epoch milliseconds date strings like: 19-FEB-12 16-FEB-12 05-AUG-09 I need this to compare these dates with the current time on the server. Anew To convert a date to seconds since the epoch: date --date="19-FEB-12" +%s Current epoch: date +%s So, since your dates are in the past: NOW=`date +%s` THEN=`date --date="19-FEB-12" +%s` let DIFF=$NOW-$THEN echo "The difference is: $DIFF" Using BSD's date command, you would need $ date -j -f "%d-%B-%y" 19-FEB-12 +%s Differences from GNU date : -j prevents date from trying to set the clock The input format must be explicitly

Convert String To date in PHP

China☆狼群 提交于 2019-11-28 23:31:08
How can I convert this string 05/Feb/2010:14:00:01 to unixtime ? For PHP 5.3 this should work. You may need to fiddle with passing $dateInfo['is_dst'], wasn't working for me anyhow. $date = '05/Feb/2010:14:00:01'; $dateInfo = date_parse_from_format('d/M/Y:H:i:s', $date); $unixTimestamp = mktime( $dateInfo['hour'], $dateInfo['minute'], $dateInfo['second'], $dateInfo['month'], $dateInfo['day'], $dateInfo['year'], $dateInfo['is_dst'] ); Versions prior, this should work. $date = '05/Feb/2010:14:00:01'; $format = '@^(?P<day>\d{2})/(?P<month>[A-Z][a-z]{2})/(?P<year>\d{4}):(?P<hour>\d{2}):(?P<minute>