Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    What's the best method for dealing with time when using PHP/MySQL? The way I've been using so far isusing a DATETIME field (I need at least seconds) and going "SELECT UNIX_TIMESTAMP(mydate) as mydate FROM..." then using time() with that result for my math and using date("H:whatever", $mynewdate) for formatting it... is there a better method? Is there a way to store a unix timestamp in mysql and being able to use the NOW() function as well? I tried the type "TIMESTAMP" but it doesn't seem to be a unix timestamp.... any help is appreciated.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  2.  

  3. #2
    Junior Member vornn's Avatar
    Join Date
    Jul 2003
    Posts
    15
    Member #
    2150
    PHP and MYSQL have different ways of storing and presenting the time. I would look at the documentation for each.

    Here's the links:

    MYSQL Timestamp command

    PHP date and time functions

    I would break up the time and date into variables which I could manipulate and store in the format I require.


  4. #3
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Well you see.. I know how it works (for the msot part), however I'm loking for the best way to do so. MySQL has many different types of date/time storage methods, and I assumed timestamp would be a unix timestamp (seconds since the unix epoch), however it's not... it's something way different. In PHP the only way I seem to be able to do any date math (adding, subtracting, etc) is using the time() (unix timestamp)... which seems like I'm doing a whole extra set of conversions that I don't need to be doing converting 2003-07-24 11:20 into the proper 102442562 format....
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:45 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com