SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Addict tedleonard's Avatar
    Join Date
    Jun 2000
    Location
    Dark side of the moon
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't get PHP to just show today's date in the following format: DD-MM-YYYY Can someone show me how? Thanks in advance!!

    -A PHP newbie

  2. #2
    SitePoint Zealot moshe_be's Avatar
    Join Date
    Dec 2000
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why not visit:
    http://www.php.net/date

    date('d-m-Y');

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will do it
    PHP Code:
    print DATE("m-d-Y"time()); 

    For all codes see the manual

    dates
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Zealot moshe_be's Avatar
    Join Date
    Dec 2000
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your cat drink too much milk

    The date function with no 2nd parameter returns the current date, so no need for the time(), and yours getting the month first while he wanted day.

    *Runs and hides*

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay so I misread is question a tad, as for the time() arg its simply there to show you how to format the date for any valid timestamp, either way it will produce the same results
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Addict tedleonard's Avatar
    Join Date
    Jun 2000
    Location
    Dark side of the moon
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx! You guys are awesome! Problem is, this is how I'm using the date, in a path, and everything works well except for that using this code:
    Code:
    <?php
    print "<INPUT TYPE=&amp;quot;hidden&amp;quot; NAME=&amp;quot;accessfile&amp;quot; VALUE=&amp;quot;/server1/users/htmlhelp/logs/access/access_";
    print DATE("d-m-Y"); 
    print "&amp;quot;>";
    ?>
    shows this:
    Code:
    <INPUT TYPE=&amp;quot;hidden&amp;quot; NAME=&amp;quot;accessfile&amp;quot; VALUE=&amp;quot;/server1/users/htmlhelp/logs/access/access_22-03-2001&amp;quot;>
    this is what I want to show up:
    Code:
    <INPUT TYPE=&quot;hidden&quot; NAME=&quot;accessfile&quot; VALUE=&quot;/server1/users/htmlhelp/logs/access/access_22-03-2001&quot;
    using the actual quote screws up the php and using character codes just displays the character code for a quote, not an actual quote.

    I'm hope I'm not being too confusing, does anyone know what to do? Thanks!!
    Last edited by tedleonard; Mar 22, 2001 at 17:58.

  7. #7
    SitePoint Zealot moshe_be's Avatar
    Join Date
    Dec 2000
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't use double quote as string start and then have it on the string.

    PHP Code:
    <?php
    print '<INPUT TYPE="hidden" NAME="accessfile" VALUE="/server1/users/htmlhelp/logs/access/access_' date("d-m-Y") . '">';
    ?>

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    printf
    ('<INPUT TYPE="hidden" NAME="accessfile" VALUE="/server1/users/htmlhelp/logs/access/access_%s">'DATE("d-m-Y"));
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Addict tedleonard's Avatar
    Join Date
    Jun 2000
    Location
    Dark side of the moon
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You guys really are awesome!! Thanks so much for your help!! I'll try it out and let you know how it goes. Thanks!

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moshe_be You keep beating me to the punch - Keep it up!
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  11. #11
    SitePoint Zealot moshe_be's Avatar
    Join Date
    Dec 2000
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nah, just my ICQ is checking for reply notification every minute

  12. #12
    SitePoint Addict tedleonard's Avatar
    Join Date
    Jun 2000
    Location
    Dark side of the moon
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IT WORKED!! You guys made my day!! Thanks so much!!

    Ted


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
  •