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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Date display in php

    hi all


    I am new to php. I have a problem in my site.I have a news and Events section in my home page,in which i want to display the latest news and events based on current server date.I am storing entire date in the database.

    database structure

    Input to Mysql database

    DATE(dd-mm-yyyy) News and EVENTS
    8-10-2005 XXXXXXXXXX
    8-10-2006 XXXXXXXXXX
    1-11-2006 XXXXXXXXXX
    14-11-2006 XXXXXXXXXX
    16-11-2006 XXXXXXXXXX
    18-11-2006 XXXXXXXXXX
    30-12-2006 XXXXXXXXXX

    #########################################################
    I need the o/p in the following format(consider 16-11-2006 is the current Server date)

    DATE(dd-mm-yyyy) News and EVENTS
    16-11-2006 XXXXXXXXXX
    18-11-2006 XXXXXXXXXX
    30-12-2006 XXXXXXXXXX
    14-11-2006 XXXXXXXXXX
    01-11-2006 XXXXXXXXXX
    8-10-2006 XXXXXXXXXX
    8-10-2005 XXXXXXXXXX



    please help me the logic or providing the code >

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    You should store dates in a database using a timestamp in an integer field, then print that out using the date() function.

    To generate a timestamp, use time(), strtotime() or in SQL use UNIX_TIMESTAMP().

    You can convert your current dates using http://www.onlineconversion.com/unix_time.htm


  •  

    Posting Permissions

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