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

Thread: timestamp

  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts

    timestamp

    in my database i want to be able to add the current time and date in a field and manipulate it to DD/MM/YYYY @ HH:MM:SS, for examples sake lets say i wanted to say
    "You joined this site on 28/3/07 11:57:47 am || 23:57:47"
    either 12 or 24 hour is fine, but can i store it like that, and it be fine.
    then pull it out and say, you have been with us on domain.com for 2 years 3 months 2 weeks 4 days 15 hours and 20 seconds

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    you would store a timestamp as yyyymmdd hhmmss and use DATE_FORMAT to display it.

    as for your question about number of days, months years etc. you would use datediff or to_days to calculate the number of days that have passed and then use the modulus operator to break those down further. you would then calculate the hours and minutes separately.


  •  

    Posting Permissions

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