Monday 15 August 2011

php - How to get exact timezone to show "you answerd days/hour ago"? -



php - How to get exact timezone to show "you answerd days/hour ago"? -

i south korea, time zone gmt+9

if comment posted 22-10-2014( don't know how daytime(am/pm))

<?php $date = date_parse_from_format('d-m-y', '22-10-2014'); $timestamp = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']); $current_time = time(); $time=$current_time-$timestamp; echo "<br/>diff ".$time; ?>

from above might how much seconds/minutes/hours based on $time. how leave timezone on server(anywhere in world)? how set exact time of post on day, can , post posted (s/m/h/d/week/month/year) ago.

here tried mysql...

<?php $current_time=time(); //echo time(); $postdate=date("d-m-y "); $date = date_parse_from_format('d-m-y', $postdate); //echo"<br/> date". $postdate; $timestamp = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']); //echo"<br/> timestamp". $timestamp; $insert =mysql_query("update time set time = '$timestamp' username='madhusudan'"); $call=mysql_query("select * time username='madhusudan'"); while($num=mysql_fetch_assoc($call)){ $time_db=$num['time']; } $time=$current_time-$time_db; echo $time; ?> input date=23-10-2014 info inserted in database=1414015200 result $time=54769 but, inserted few sec ago?????? how solve bro.....

php mysql

No comments:

Post a Comment