Jump to content

solidstan

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by solidstan

  1. Thanks, you make it sound easy.

    I was getting "23/2/14" which I assume was a string.

    I had tried so many different ways, I was convinced this was never going to work.

    I had tried the datetime() function, but could only get current date.

     

    Your Solution works perfectly. Thanks Millions.

     

    my code is procedural, the bit of Object O posted above was what I have copied from elsewhere.

     

    Thanks again, I now understand.. Solved! :)

  2. function customData($con,$num,$driverListDate,$rotaDate,$noOfLines,$line){    if($line==getNewLine($con,$num,$driverListDate,$rotaDate,$noOfLines)) {      //echo date("M d, Y" );      //echo date('M d, Y', $rotaDate);        $date = DateTime::createFromFormat('d/m/Y', $rotaDate);     return $date;

     

     

    Catchable fatal error: Object of class DateTime could not be converted to string

    Think im gona have to give up with this stuff.

  3.  function customData($con,$num,$driverListDate,$rotaDate,$noOfLines,$line){    if($line==getNewLine($con,$num,$driverListDate,$rotaDate,$noOfLines)) {      //echo date("M d, Y" );      //echo date('M d, Y', $rotaDate);     // return $rotaDate;        $rotaDate = DateTime::createFromFormat('d/m/Y', $date1);            echo $date1;            echo $rotaDate;    }  }

    No, This does nothing!

     

     

  4. Im sorry. Im new very new to php. Are you asking me if $rotaDate is a string?

    Im not sure, that is why I showed it here:-

    $rotaDate = date('23/2/14');

    If I change this format in any shape or form, the that second function(which I copyed and pasted from the net) Fails!

    Right now, my php page works perfect, except for the format that it outputs.

  5. I have a working php file, which use lots of custom dates.

    I am try to simply format an echoed out put, with no success(very new to php).

    hope someone can help.

    $rotaDate = date('23/2/14');$driverListDate = date('5/1/14');
    //Calculate the differance between 2 dates function dateDiffInWeeks($date1, $date2,$noOfLines){    $first = DateTime::createFromFormat('d/m/Y', $date1);    $second = DateTime::createFromFormat('d/m/Y', $date2);    return (((floor($first->diff($second)->days/7))/$noOfLines) - floor((floor($first->diff($second)->days/7))/$noOfLines))*$noOfLines; }
    function customData($con,$num,$driverListDate,$rotaDate,$noOfLines,$line){    if($line==getNewLine($con,$num,$driverListDate,$rotaDate,$noOfLines)) {      //echo date("jS F Y" );      //echo date('jS F Y', $rotaDate);      return $rotaDate;    }  }

    Im trying to echo my date as "jS F Y" format.

    This of course is not my full php file, but im sure its all thats relevant.

    Thanks in advance!

  6. I am very new to PHP and SQL, and enjoying learning through W3School.I need alittle help with my function, to return a single value from a sql database.

    function lineData($con,$num,$row){    $Result = mysqli_query($con,"SELECT Line FROM DriverList WHERE DriverNumber = $num");         $output =  mysql_query($Result);      return $output   }

    Hope you can see what i'm trying to do. Any help and tips, would be appreciated..

     

    Thanks in advance!

×
×
  • Create New...