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 3 of 3

Thread: SYSDATE() views

  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question SYSDATE() views

    Hi there, I currently store a timestamp in my database to keep track of the last time an entry was updated via the SYSDATE() SQL function.

    I was wondering if there was an easy way to display this sysdate in a simple format

    so instead of displaying 2006-11-30 04:46:51
    it displays "30-Nov-06" or "Today" etc...

    Many thanks

    WB

  • #2
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Check out the date() php function.

    Extract the date from your database, set it as a variable and format it with the date() function.

    date("d-M-y", $myDate)

    If you want it to say "Today" then just run a conditional that asks if date() is equal to date("d-M-y", $myDate). If so, then print "Today" instead of the date.

    Easy-Peasy

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,106
    Thanks
    11
    Thanked 101 Times in 99 Posts
    or look at your DB's built in commands .. e.g. in MySQL you can

    Code:
    "SELECT DATE_FORMAT('timefield','%d-%M-%Y) as pretty_date FROM ...etc
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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