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.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Timestamp

  1. #1
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    Could somebody out there drop me a freebee on how i can format my date.

    this is what i have.

    //this variable produces a date in the format ex. 0309110830
    <?echo $row["date"]; ?>

    I would like to put this into something a little more user friendly like "03/09/11 8:30am". I have all the code like "jS, l, H g" etc... I just can't figure out how to put it all together.

    Thanks for your help!
    Eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Use the date function, it will interpret a lot of different date formats (UNIX timestamp, MySQL timestamp, etc) use soemthing like:
    PHP Code:
    echo date("h:i:s"$row['date']); 
    Read up more on it at www.php.net/date
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    Almost...

    i posted the code that you supplied and it formatted the date very well. but the date is now fixed at January 18th, 2038.

    I read that the timestamp can generate a date between the dates of dec 13, 1901 and jan 19, 2038. i am one day away from "PHP Armageddon".

    any suggestions?
    Eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.

  5. #4
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    It doesn't seem like a problem with the way PHP is formatting the date, because since you have $row['date'] as the second parameter of the function it will not default to the current time as it would with no second parameter.

    What was your generated output before, and whatis the value of $row['date'] prior to the date() function being used? Once we know this, I think we can better understand what's going on.
    - Brian

  6. #5
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    timestamp...

    when i use: <?echo $row["date"]; ?> i get the current time in the following format, "0309110830".

    when i use the code: <?echo date("m/d/y" , $row["date"]); ?> Brak suggested the format is perfect but the date stays static at "01/18/38"

    What do you think?

    Eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.

  7. #6
    Member Black Vivi's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    75
    Member #
    1072
    you can change the format, but not the date itself, unless you change the value of $row["date"]
    Download Firebird now!

  8. #7
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    i don't want to change the date itself. when i just use <?echo $row["date"]; ?> it gives me the right date in an uneasy-to-read format.

    BUT, when i try to format it using the methods suggested in this forum, i get a fixed date for january 18, 2038.

    Am i using the 'date' function incorrectly?

    eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.

  9. #8
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    What is the value of $row["date"] ?

    Is it a timestamp coming from a MySQL database ?

    The date function formats the date according to the optional timestamp paramater, and if absent uses the current time which is in your case $row["date"]

    Have you tried the mktime() function in place of your $row["date"] as described in the date() example ?
    - Brian

  10. #9
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    It seems you're extracting the date from MySQL's timestamp function, as this presents a readable date (instead of PHP's timestamp function which requires som more decoding)
    Try the following piece of code:
    PHP Code:
    <?php
     $datetime
    $row["time"];
     
    $yearsubstr($datetime,0,4);
     
    $monsubstr($datetime,4,2);
     
    $daysubstr($datetime,6,2);
     
    $hoursubstr($datetime,8,2);
     
    $minsubstr($datetime,10,2);
     
    $secsubstr($datetime,12,2);
     
    $orgdatedate("d.M  Y G:i "mktime($hour$min$sec,  $mon,  $day$year));
    ?>
    The first part of the $orgdate-definition ("d.M Y G:i",.... is the definition of the timeformat you'de like to display. The complete format list is:

    // a/A= am eller AM
    // H=24 hour format
    // i=minutes
    // s=seconds
    // j/d= day of month 5/05
    // D/l= sat/saturday
    // w=weekday number
    // M/F= jan/january
    // y/Y= year 03/2003
    // z= day of the year (365)
    // S= th, nd, st
    S. Rosland

  11. #10
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    working! now timezones

    Thanks for everyones help. i got the timestamp working now using Rosland's code but i think i initially messed up by setting the timestamp as timestamp(12) instead of timestamp(14)! I read that you could use timestamp(12) so why didn't this work for me?

    Now that the time is working, how can i adjust it to a specific timezone? Also, what is the default timezone?

    Thanks again!
    eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.


Page 1 of 2 1 2 LastLast

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 04:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com