Results 1 to 5 of 5

Thread: date format

  1. #1
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink date format

    hi all,
    i have date stored in database in yyyy-mm-dd format..
    bt while displaying on page i wanna display in d-m-yyyy fomat...
    how do i do tht?
    like eg.....
    event_date=2007/01/20-------saved in database..
    bt i want to display like 20th Jan 2007....
    similiarly for time...in database it is saved as 02:30:00....
    bt i want to display it as 02:30 AM....


    hw do i do this?


    its urgent

    regrds
    varsha

  2. #2
    Join Date
    Jan 2007
    Location
    Surrey, UK
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    if using a sql database (eg mysql) change the date format in your query.
    eg

    Code:
    SELECT DATE_FORMAT(mydatefield, '%D %b %Y') from mytable
    where mydatefield is the date field name and mytable is the table.

    look here for all the details:

    http://dev.mysql.com/doc/refman/4.1/...functions.html

  3. #3
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hey thnks a lot...
    i tried tht it..works..well...
    thnks...cu.
    varsha


    Quote Originally Posted by mike_p View Post
    if using a sql database (eg mysql) change the date format in your query.
    eg

    Code:
    SELECT DATE_FORMAT(mydatefield, '%D %b %Y') from mytable
    where mydatefield is the date field name and mytable is the table.

    look here for all the details:

    http://dev.mysql.com/doc/refman/4.1/...functions.html

  4. #4
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Hi, im new here, nice forum!

    i got a problem... What about if you want to run a script every monday, everytime a user log in, like a monday's surprice

    if (date("D") == 'Mon') {
    RUN SCRIPT; }
    else { NOTHING }

    the problem is, with this method the user could change their computer time and get the surprice any day at any time, just need to change their computer date to monday. How can i do to instead of check for the user's time, to check the time of the server where the website is hosted?

    Thanks!

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Answered in the other thread
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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
  •