English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

am using a PHP/MySQL system

2007-01-24 18:18:01 · 2 answers · asked by theKenyan 3 in Computers & Internet Programming & Design

2 answers

Use the PHP function strtotime().

Example:
$newdate=strtotime("+30 days");

You can also add an optional parameter (a unix date) after the period you wish to add/subtract. See the source link for more info.

2007-01-24 18:35:06 · answer #1 · answered by mr_cabbageman 4 · 0 0

You cant define the timestamp for 30 days since it changes every second...
but you can calculate it use this code. This example shows subtracting 30 mins from the current time
you can do
$hours + 30 for 30 timestamp


$timestamp = time();
$date_time_array = getdate($timestamp);
$hours = $date_time_array['hours'];
$minutes = $date_time_array['minutes'];
$seconds = $date_time_array['seconds'];
$month = $date_time_array['mon'];
$day = $date_time_array['mday'];
$year = $date_time_array['year'];

// use mktime to recreate the unix timestamp
$timestamp = mktime($hours,$minutes - 30,$seconds,$month,$day,$year);
$delaytime = $timestamp;

2007-01-25 02:37:06 · answer #2 · answered by w2pc.com 3 · 0 0

fedest.com, questions and answers