#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    While i work on my acution site, i need to input into the database the time the user submitted the auction, and the time + the duration of the auction. How can i store these two values in variables.

    Thanks


    Sam
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    $starttime=date(mktime());//add to db//
    //when over//
    $fintime=date(mktime());//add to db//

    date(mktime());returns an integer value (seconds since 01/01/1970) for the date, store this both times & you can subtract the difference to get the number of seconds between the 2 dates - then its just a bit of math to work out the time in hours/mins etc.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    very interesting, care to help me with the math
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Washington, USA
    Posts
    52
    Rep Power
    15
    Here's a link to an article I wrote which should help you with calculating the amount of time between events using a UNIX timestamp. I use Perl in the example, but it doesn't matter really that much which language you use, the way to do it is pretty much the same:
    http://www.tdscripts.com/time_dates.html

    hope this helps


    ------------------
    <UL TYPE=SQUARE>
    <LI> TD Scripts
    <LI> Script School
    <LI>php-scripts
    </UL>
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    I really dont understand this article, i suppose what i can do is get the current time in seconds, then divide it by the number of seconds in a year and add it to 1970, giving me the year, correct? and just repeat this patern for the other elements of time.

    I dont understand why i would need any fancy unix functions, but then again, like i said, i dont understand
  10. #6
  11. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    rpgswap.com,

    Read the following article..
    http://www.phpbuilder.com/columns/akent20000610.php3

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Washington, USA
    Posts
    52
    Rep Power
    15
    rpgswap,

    Hmmm, if you don't understand that if you subtract a past point in time in seconds from a future point in time in seconds and that the result is the amount of seconds that has elapsed well ... then you better hit the bricks and restudy the concept, because to me, anyway, that makes pretty good sense Nothing "UNIX complicated" about it, I think that is called basic time elapsed.

    While writing this response how many seconds have elapsed, maybe 180 seconds? There's 3 minutes!

    180 seconds divided by 60 = 3 minutes

    Anybody else not understand my article? Maybe I'm in left field and I need to rework it. First time I've received the feedback that conceptually it couldn't be grasped ...
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    Look man, i didnt understand the whole article, dont take offense. I got the gist of the firs half, which is what matters, but the rest wasnt clear to me. I take offense in how you reacted towards my lack of comprehension. Sorry i invaded you by saying i found your delicate code ambiguous. I thought we were here to help one another...
  16. #9
  17. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    errr - your tutorial was good Tdavid - but there is no need to be rude - PHP 'aint PERL whatever anyone says , & because of that .... we can do this! (did not think of it before).

    $el is the start date,
    $el2 is the finish date
    getdate()is way cool!

    <?
    $el=967239302;//from db//
    $el2=967239000;//from db//
    $elap=$el-$el2;// get difference //
    $elapsed=getdate($elap);// Magic!//
    echo "days".$elapsed[days]."<br>";
    echo "hours".$elapsed[hours]."<br>";
    echo "mins".$elapsed[minutes]."<br>";
    echo "secs".$elapsed[seconds]."<br>";
    ?>

    So no Math needed after all (I got a 'U' (unclassified) in Math at school).


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Washington, USA
    Posts
    52
    Rep Power
    15
    Yikes I guess smilies don't work on the internet for some people Firepages and RPGswap, please chill out. I wasn't taking offense, I was being genuine in asking for feedback, not trying to be or come across as rude Really

    Apparently both of you took my comments above in the wrong way and I apologize but the use of smilies usually means one is SMILING as they say something

    Am I here to help people? Doh! Of course Take a look at the date I registered for this forum and see how many people I've already answered questions from Believe me, if I'm going to flame someone, they'll know it, I won't beat around the bush

    Let's move on, shall we, and stick to PHP and not getting sensitive? I should have started a different thread and asked for feedback on the article, instead of using a reply to comment here to ask for feedback. While I didn't take offense (actually I was curious and wanted to take feedback to make it better and more lucid) to my article not being comprehended, it is clear to me now that you two thought I did. Thank you for the feedback Good and bad feedback is helpful, really it is
  20. #11
  21. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    LOL - Tdavid -sorry but its funny cos I think that the board has reset your profile - it shows you joined 22nd August this year & have 27 posts! - I have seen you around a long time before that!

    I know what you are saying Tdavid but the post came accross as a little condescending, I know its hard to read these things sometimes, so sorry if I got you wrong.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    its cool tdavid. I understand. Your article isnt bad at all, it just confused me. Its well written and clear, but I think it couldbe better improved by being more thorougly explained once you get into the comparing events in a time section. Firepages-what you just posted was brilliant, screw math, i love you

    Thanks again guys, i cant wait til my site is totally done! i know one day ill finish

    cyaz

    Sam

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. database date selection problem
    By kidsleep in forum MySQL Help
    Replies: 0
    Last Post: January 31st, 2004, 10:50 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo