hello,i am editing a program for e-ticketing.and i am having a hard time figuring out on how will i convert time into am/pm..in the process of buying ticket,we have to choose time departure and if its am or pm,then the problem is i dont know how will i put it into sentence.. thanks

8 Years
Discussion Span
Last Post by vinryyesha

If you have a date and a time such as 2010-08-24 18:00 you can first convert this to a (unix) time stamp with the strtotime command. You can then use that time stamp in the date command to convert it to whatever display format you need:

$timestamp      = strtotime("2010-08-24 18:00");
   $date_and_time  = date("Y-m-d g:i A",$timestamp);
   $just_time      = date("g:i A",$timesatmp);

do {
        !isset($_SESSION['userId'])) { 

            header("Location: index.php?action=logoff"); 


//get currentship
    $cur_ship = $_POST['shipTrip'];
    $_SESSION['cur_ship'] = $cur_ship;
    $terminal = $_SESSION['computer'];

  //disable error reporting


 //set the default timezone  

$terminalFee = $montenegrofunc->select_currentTerminalFee();
$currentTerminal = $montenegrofunc->select_currentTerminal();

$currentPort = $currentTerminal[0][0];
$destination = $_REQUEST['destination'];

[COLOR="Green"][B]//this is the part that i am not sure on what to do..[/B][/COLOR]

$timeDeparture = date ("g:i A",$timestamp);
$timeDeparture = $_REQUEST['time'].$_REQUEST['ampm'];
}elseif($_REQUEST['ampm'] == "1 to 12"){

$portFareMatrix = $montenegrofunc->select_tblFareMatrix($currentPort,$destination,$_REQUEST['discount_type'],$_REQUEST['class_type'],$_REQUEST['Insurance_w']);
$passengerType = $montenegrofunc->select_discountFee($_REQUEST['discount_type']);
$vehicleTypeFee = $montenegrofunc->select_vehicleTypeFee($_REQUEST['vehicleType']);
$classType = $montenegrofunc->select_classType($_REQUEST['class_type']);
//$sizeVehicle = $montenegrofunc->select_sizeVehicle($_REQUEST['vehicle_size']);
$ShippingFareMatrix = $montenegrofunc->select_tblRoroFareMatrix($currentPort,$destination,$_REQUEST['vehicle_size']);
//$print_ticket = $montenegrofunc->select_SalesPrint();
//$insuranceFare = $montenegrofunc->select_insuranceFare($currentPort,$destination,$_REQUEST['discount_type']);

$currntTerFee = $terminalFee[0][0];
$originPort = $portFareMatrix[0]['origin'];
$destPort = $portFareMatrix[0]['destination'];

$vehicleType = $vehicleTypeFee[0][2];
$vehicleFare = $vehicleTypeFee[0][11];

$class_type = $classType[0][2];

$speDscount = $_REQUEST['specialDiscount']/100;

$description = $_REQUEST['description'];
$value = $_REQUEST['value'];

$user = $_SESSION['username'];
$pos = $user[0];
$upper = ucfirst($pos);
$workstation = $montenegroconf->workstation;
$transac_num = "P".$upper.strtoupper(date("ydM")).$workstation; 
$insurance_num = "PBI".$upper.strtoupper(date("ydM")).$workstation; 
$discount_type = $passengerType[0][2];

if($_REQUEST['discount_type'] == "D007"){

$discount_amt =  $terminalFee[0][1] * $speDscount;
$terminalFare = $terminalFee[0][1] - $discount_amt;


$discount_amt =  $terminalFee[0][1] * $passengerType[0][3];
$terminalFare = $terminalFee[0][1] - $discount_amt;
$vshipping_fare = $ShippingFareMatrix[0][4];
$vinsurance = $ShippingFareMatrix[0][5];
$shipping_fare = $portFareMatrix[0]['fare'];
if($_REQUEST['Insurance_w'] == 'I002'){
$insur = 0.00;
}else if($_REQUEST['Insurance_w'] == 'I001'){
$insur = $portFareMatrix[0][8];
$fare = $terminalFare + $shipping_fare + $insur + $vehicleFare + $value + $vshipping_fare + $vinsurance;

$status = 0;
$flag = 0;
$length = 30;
//$teller = "eloy";

$exioAddress = $currentTerminal[0][4].":52146/graphic8.bmp -#";
//$exioAddForLogo = $select_origin[0][6].":52146/graphic2.bmp -#";

 if($destination != "")

                    function generateKey($length) 
                        //$timeValue = strftime("%Y%H%M%S");
                        $timeValue = strftime("YmdHis");
                        $timeComponent = dechex($timeValue);
                        $limit = $length - strlen($timeComponent);
                        $val = '';
                            $str = 'abcdefghijklmnopqrstuvwxyz0123456789' . time() ;
                            $shuffled = str_shuffle($str);
                            $val .= substr($shuffled, 0, 1);

                        //concatenate hex of time value
                        $val = $val . $timeComponent;

                        return $val;

                        $size = '10x10';
                        $path = 'montenegro/barcode';
                        $scale = '-scale 100%x100%';

                            //setup barcode content
                              $code = "monppa".generateKey(32);
                              $barcode = $code;
                              //$refNumber = "R" . generateKey(32);
                              //generate ticket and print ticket to exio        
                                exec("java dmCreate ".$code." ".$size." ../".$path."");

                                //for printed ticket printing
                            exec("convert ../".$path."/".$code.".bmp -chop 23x1  -extent 26%x26% -depth 1 -monochrome -sample 600%x600% $scale ../".$path."/".$code.".bmp");

                            //barcode to display
                            $dmcode = "../".$path."/".$code.".bmp";

                                //add ticket to the terminal fee sales database
                                //$ticket_no, $barcode, $amount, $purchase_date, $expiry_date, $status, $terminal_id        
                                $purchaseDate = date("Y-m-d, H:i:s");
                                $expiration_date = date("Y-m-d, H:i:s", strtotime("+7 days"));                      

                            //place to exio image holder in case logos needs to be printed
                            //exec("cURL -w %{size_upload} -T images/pnr.bmp " . $exioAddForLogo );

                            //place to exio image holder in case barcode needs to be printed
                            $curl_result = exec("cURL -w %{size_upload} -T ".$dmcode." " . $exioAddress );      

                                //place to exio image holder in case barcode needs to be printed
                            //$curl_result = exec("cURL -T barcode/".$code.".bmp " .$exioAddress );

                            //convert string to int
                            $curl_result = ((int)$curl_result);

                            $barcode_size = 3000; //3182 bytes -> actual barcode size;                    

                            //if(1) //$curl_result >= 3000)
                            if($curl_result >= 3000)

                            $okToPrint = 1;

                        // add ticket to local series database
                    //$montenegrofunc->record_salesSeries($barcode, $status);

                        // add ticket to local sales database

                    $montenegrofunc->record_sales($transac_num, $barcode, $class_type, $discount_type, $discount_amt, $terminalFare, $originPort, $destPort, $shipping_fare, $insur, $vehicleType, $vehicleFare, $description, $value, $fare, $vshipping_fare, $vinsurance, $flag, $purchaseDate, $_SESSION['username'], date("M"), $_REQUEST['lastName'], $_REQUEST['firstName'], $_REQUEST['middleName'], $_REQUEST['passAge'], $_REQUEST['passAddress'], $_REQUEST['shipTrip'], $timeDeparture);
                        $currentTicket = $montenegrofunc->select_currentTicket();
                        $transac = $currentTicket[0][0];
                        $series = $currentTicket[0]['series_num'];
                        //$string = $teller;
                        $refNumber = $transac.$series;

                        $montenegrofunc->update_ticketSeries($barcode,$refNumber); //update ticket

                 if($_REQUEST['Insurance_w'] == 'I001'){
                        $montenegrofunc->record_insurancesales1($originPort, $destPort, $flag, $_SESSION['username'], $_REQUEST['lastName'], $_REQUEST['firstName'], $_REQUEST['middleName'], $_REQUEST['passAge'], $_REQUEST['passAddress'], $_REQUEST['shipTrip']);
                            //add ticket to omni central sales database
                            //$pnrcentralfunc->record_sales($teller, $entrystation, $exitstation, $barcode , $purchase_date, $fare, $status, $refNumber, $discType);

                                $okToPrint = 0; 
                                header("Location: main.php");       

//header("Location: buyTicket.php?code=".$barcode."&okToPrint=".$okToPrint."&destination=".$exitstation);
//header("Location: buyTicket.php?okToPrint=".$okToPrint);
header("Location: viewTicket.php");
}else{ header("Location: index.php?action=logoff");}

Edited by mike_2000_17: Fixed formatting


You need to post your code using code tags. If you have a question or if you are having a problem, please state what it is.

Edited by Reverend Jim: Fixed formatting


on the program there is a date and time already.we can filter it by dates which includes already the time..now i want to put the time departure which the user have to choose on the option value of time(1:00-12;00) and chooses if its am or pm...now the problem is how am i going to add it on the database and have a separate filtering for the sales reports by time..and ampm also....thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.