Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    40
    Thanks
    9
    Thanked 0 Times in 0 Posts

    converting DATETIME using strtotime()

    Hi,
    I am trying to convert '2008-07-19 04:10:47' into day month year format for a review table but keep getting an error.

    Here is my code
    PHP Code:
    $date strtotime($row['dateCreated']);
    $ratingTable$ratingTable"<tr><td>" date(d F Y$date) . "</td></tr>"
    I can't see anything wrong but am getting an ENCAPSED_AND_WHITESPACE error. Can anyone help please ?

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    Try:

    PHP Code:
    $date strtotime($row['dateCreated']);
    $ratingTable$ratingTable"<tr><td>" date("d F Y"$date) . "</td></tr>"
    The formatting specification for date needs to be enclosed in quotes.
    Dave .... HostMonster for all of your hosting needs

  • Users who have thanked djm0219 for this post:

    simonwraight (07-23-2008)

  • #3
    New Coder
    Join Date
    Nov 2007
    Posts
    40
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks, it's so obvious when someone points it out.

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    It's also worth noting that using $date as a variable name may result in confusion. You could put the conversion "in-line" and save a variable assignment in the process.

    PHP Code:
    $ratingTable$ratingTable"<tr><td>" date("d F Y"strtotime($row['dateCreated'])) . "</td></tr>"
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •