mktime

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

mktime

Post by prasadharischandra »

if i convert to 72 hrs mktime
after that
i want to convert to mktime value to 72 hrs how to do that
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What exactly are you trying to achieve? Are you trying to add 72 hours to a timestamp or what? You really need to explain yourself a little bit better so that we can help you.

Mac
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

time

Post by prasadharischandra »

my code is
$today = date("j F ,Y");

#.........Month array..............
$allMonths["Jan"]=1;$allMonths["Feb"]=2;$allMonths["Mar"]=3;$allMonths["Apr"]=4;
$allMonths["May"]=5;$allMonths["Jun"]=6;$allMonths["Jul"]=7;$allMonths["Aug"]=8;
$allMonths["Sep"]=9;$allMonths["Oct"]=10;$allMonths["Nov"]=11;$allMonths["Dec"]=12;
#----------------------------------------------

# get Hours and Minute
$timeTake=explode(":",$select_time);
# get month and Year
$mYear=explode(" ",$select_myear);
# get set variables
$monthTake=$allMonths[$mYear[0]];
$yearTake=$mYear[1];
$dateTake=intval($select_day);
$hourTake=intval($timeTake[0]);
$minuteTake=intval($timeTake[1]);

# now make PHP time stamp for Flght Depature Time
$flightDepTime=mktime($hourTake,$minuteTake,0,$monthTake,$dateTake,$yearTake);

i want to take "$flightDepTime" in convert to previous value
i.e if i input 72 hrs then it will become a mktime
so i want to take a 72

for example

1028656800 ------convert to hours (72 or..)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You shouldn't be converting 72 hours to a timestamp. Read this:
http://www.php.net/manual/en/function.mktime.php
which will explain what a timestamp is. You could have two timestamps which are 72 hours apart and you could subtract one from the other to get the difference in seconds between them. Since you'd have an answer in seconds it's easy enough just to divide that by 3600 to get the number of hours.

PHP has a lot of date and time functions you should read up on them:
http://www.php.net/manual/en/ref.datetime.php

Mac
Post Reply