Page 1 of 1
Time
Posted: 2013 Jan 20 13:19
by Koti
Padarau sql column "time" su type INT. Kuomet serveris man grazina tam tikra laika, gaunu mazdaug toki 1358680594. Cia kaip suprantu yra unix time, taciau kaip man ji paverst i normalu laika, kad rodytu menesi, diena ir valandas:minutes:sekundes ?
Re: Time
Posted: 2013 Jan 20 13:36
by TETYYS
php.net/manual/en/function.date.php
Re: Time
Posted: 2013 Jan 20 13:49
by Koti
Turiu koda
Code: Select all
<?php// Make a MySQL Connectionmysql_connect("localhost", "log", "pw") or die(mysql_error());mysql_select_db("db") or die(mysql_error()); // Get all the data from the "example" table$result = mysql_query("SELECT * FROM log_connect") or die(mysql_error()); date_default_timezone_set('UTC');echo "<table border='1'>";echo "<tr> <th>IP</th> <th>Nick</th> <th>Time</th> </tr>";// keeps getting the next row until there are no more to getwhile($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['ip']; echo "</td><td>"; echo $row['nick']; echo "</td><td>"; echo $row['time']; echo "</td></tr>";} echo "</table>";?>
Tai kurioj cia man vietoj irasyt ta
Code: Select all
echo date('l jS \of F Y h:i:s A');
Kad $row['time'] atvaizduotu normalu laika, o ne 1358682532 ?
Re: Time
Posted: 2013 Jan 20 16:54
by aaarnas
--->>>
Code: Select all
echo date('l jS \of F Y h:i:s A', $row['time']);
Be to, mysql'e galima datą saugoti ir datos formatu, ne timestamp.
Re: Time
Posted: 2013 Jan 20 17:25
by Koti
Aciu uz koduka, taciau kai bandau per mysql su date, tai man 0000-00-00 rodo.
Re: Time
Posted: 2013 Jan 20 19:58
by TETYYS
tai varchar