SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict brain's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date notation error

    I have an date field in my database and letting that date show in a php document:

    <?php echo $rsPartylist->Fields("datum")?>

    Now I want the outcome not to be: 2001-10-09 but just 09-10. If i'm using the DW ultradev command on the recordset. It generates the following code:

    <?php echo DoDateTime( $rsPartylist->Fields("datum"), 'jS F Y') ?>

    but viewing this live -->

    Warning: unexpected error in date() in d:\apache\htdocs\partylist_oll6jaaq6.php on line 60

    Is there another (working) code I can use ?

    Greetz Brain

  2. #2
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dunno wtf all that code is, but since you said it "generated" the code, i can see why it's overly complicated.
    to echo the date like you wnat do this:
    PHP Code:
    <?php
    $the_date 
    date("d-m");
    echo 
    $the_date;
    ?>
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btw, the last part in your code ("jS F Y")
    php would print something like this:
    10th September 2001
    what i posted will do the 09-10 like you want.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    SitePoint Addict brain's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not exactly what I need...

    That's not what I meant. With that code today's date appears. What I need is the date generated from the database (via a recordset) has to transform from 2001-09-15 (as mySQL date insertion requires) to 15-09. I hope you understand what I mean.

    Greetz

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here, just pull the date outta your database, and use this code to convert it:
    PHP Code:
    <?

    $string 
    "2001-09-07"// date in database
    $array explode("-"$string);

    echo 
    $string// this prints the date as in the db
    print "<BR>";

    $date mktime(0,0,0,$array[1],$array[2],$array[0]); 

    $new_date date("m-d"$date);
    echo 
    $new_date;
     
    ?>
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you want it month-day or day-month?
    well, if the above isn't right, just switch the d and m
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

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