date_format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • toddlahman@gmail.com

    date_format

    I'm trying keep the date, and trim off the time when I pull it from a
    wordpress datebase in a while loop. Here's what I'm doing right now:

    $lmdate = mysql_query("SE LECT post_modified FROM wp_posts WHERE
    post_status = 'publish'");

    while ($date = mysql_fetch_arr ay($lmdate, MYSQL_ASSOC)) {
    $lm = $date['post_modified'];

    echo $lm;

    My out put is:

    2007-10-03 12:55:19

    I'd like the output to be just the date without the time:

    2007-10-03

    Thanks you,

    HG
  • MikeB

    #2
    Re: date_format

    On Jul 22, 12:01 am, toddlah...@gmai l.com wrote:
    I'm trying keep the date, and trim off the time when I pull it from a
    wordpress datebase in a while loop. Here's what I'm doing right now:
    >
    $lmdate = mysql_query("SE LECT post_modified FROM wp_posts WHERE
    post_status = 'publish'");
    >
    while ($date = mysql_fetch_arr ay($lmdate, MYSQL_ASSOC)) {
    $lm = $date['post_modified'];
    >
    echo $lm;
    >
    My out put is:
    >
    2007-10-03 12:55:19
    >
    I'd like the output to be just the date without the time:
    >
    2007-10-03
    >
    Thanks you,
    >
    HG
    Take the leftmost 10 characters?

    Comment

    • MikeB

      #3
      Re: date_format

      On Jul 22, 12:26 am, MikeB <MPBr...@gmail. comwrote:
      On Jul 22, 12:01 am, toddlah...@gmai l.com wrote:
      >
      >
      >
      I'm trying keep the date, and trim off the time when I pull it from a
      wordpress datebase in a while loop. Here's what I'm doing right now:
      >
      $lmdate = mysql_query("SE LECT post_modified FROM wp_posts WHERE
      post_status = 'publish'");
      >
      while ($date = mysql_fetch_arr ay($lmdate, MYSQL_ASSOC)) {
      $lm = $date['post_modified'];
      >
      echo $lm;
      >
      My out put is:
      >
      2007-10-03 12:55:19
      >
      I'd like the output to be just the date without the time:
      >
      2007-10-03
      >
      Thanks you,
      >
      HG
      >
      Take the leftmost 10 characters?
      should have added this:

      Check out


      Comment

      • Geoff Berrow

        #4
        Re: date_format

        Message-ID:
        <6ce52365-ad91-4da1-a06a-9768671499f1@j3 3g2000pri.googl egroups.comfrom
        toddlahman@gmai l.com contained the following:
        >My out put is:
        >
        >2007-10-03 12:55:19
        >
        >I'd like the output to be just the date without the time:
        >
        >2007-10-03
        I think you need to check out the mySql date formatting functions.

        --
        Geoff Berrow 011000100110110 0010000000110
        001101101011011 001000110111101 100111001011
        100110001101101 111001011100111 010101101011
        The Slippery Hill Boys Tel: 07985 425932. American themed barn dances and bluegrass performances. Stoke on Trent, Newcastle under Lyme, Staffordshire, Cheshire and surrounding areas.

        Comment

        • Suhas Dhoke

          #5
          Re: date_format

          On Jul 22, 10:01 am, toddlah...@gmai l.com wrote:
          I'm trying keep the date, and trim off the time when I pull it from a
          wordpress datebase in a while loop. Here's what I'm doing right now:
          >
          $lmdate = mysql_query("SE LECT post_modified FROM wp_posts WHERE
          post_status = 'publish'");
          >
          while ($date = mysql_fetch_arr ay($lmdate, MYSQL_ASSOC)) {
                          $lm = $date['post_modified'];
          >
                  echo $lm;
          >
          My out put is:
          >
          2007-10-03 12:55:19
          >
          I'd like the output to be just the date without the time:
          >
          2007-10-03
          >
          Thanks you,
          >
          HG

          You can format the date, by using the date() function of php.

          like this..

          echo date('Y-m-d', strtotime($lm)) ;

          It will output like this.. 2007-10-03.

          Cheers..!!!

          Comment

          • Michael Fesser

            #6
            Re: date_format

            ..oO(toddlahman @gmail.com)
            >I'm trying keep the date, and trim off the time when I pull it from a
            >wordpress datebase in a while loop. Here's what I'm doing right now:
            >
            >$lmdate = mysql_query("SE LECT post_modified FROM wp_posts WHERE
            >post_status = 'publish'");
            >
            >while ($date = mysql_fetch_arr ay($lmdate, MYSQL_ASSOC)) {
            > $lm = $date['post_modified'];
            >
            > echo $lm;
            >
            >My out put is:
            >
            >2007-10-03 12:55:19
            >
            >I'd like the output to be just the date without the time:
            >
            >2007-10-03
            Use MySQL's DATE() function.

            Micha

            Comment

            Working...