18 wrz 2009

Obliczanie różnicy czasu

echo (strtotime("2009-09-14 15:55:00")-strtotime("2009-09-14 11:00:02"));
$hour_ts = 3600;
$day_ts = 86400;
$modif_ts = strtotime("-10 day");
$modif_ts = strtotime("-4 hours");
$modif = strtotime("2009-09-14 15:55:00");
$modif_ts = strtotime($modif);
$now_ts = time()+1;
$d_ts = $now_ts-$modif_ts;
echo $d_ts .'';
18 wrz 2009

Dump i import tabeli mysql w php

dump:

$command = 'mysqldump -h localhost -B baza -u user -phaslo --tables Panstwa --no-create-info --skip-lock-tables --compact --comments --complete-insert > /data/dump/Panstwa.sql 2> /data/dump/err_Panstwa.txt';
exec($command);

import:

$command = 'mysql -h localhost -B baza -u user -phaslo --default-character-set=utf8 < /data/dump/Panstwa.sql';
exec($command);

kopiownie:

$sql = 'INSERT INTO Panstwa SELECT * FROM b_Panstwa';
mysql_query($sql);