FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


displaing the date





AlexandruDan
I have this problem:
i save the date in an mysql data base using time () - in seconds - and i try to display it as a date d-m-y, but i can't figure it out...
How can i display the date using something like this:
date ("d-m-y", time(obj['data']))
AftershockVibe
What do you mean when you say the time in the database is stored as the time in seconds? Seconds since the epoch? I'd be much easier just to save as a timestamp and no need to faff with the code later on? (less storage vs more processing argument).

That way you can just do:
Code:
date ("d-m-y", obj['data']);



However, if you are stuck with seconds you might want to try the following:
Code:
date ("d-m-y", time(0) + obj['data']);


I've not tested it but that should do what you want.
AlexandruDan
i save the time in seconds since the epoch. my problem is to store the date when i added the item in the database and display it normaly, as m-d-y
kv
You have 2 options

1. Convert the time in seconds since epoch to date and store it in database
2. Store the time in seconds since epoch in database and convert it before display

Which ever method you choose, use date() method to format it to proper string. You will have to convert the time in seconds since epoch to timestamp before passing it to date by multiplying it by 1000 (milliseconds since epoch).
AOP Web Development
i don't why you saved it into seconds and you want to display it in date but. I hope this would help

Code:


$st = strftime("%Y-%m-%d", strtotime($row['data']));

i don't know if that would work.


but as i have known the other thing to display the date in different format coming from the database is by using strftime. just try to search it on php.net.

Laughing Laughing Laughing Laughing Laughing
AlexandruDan
Thanks for the solutions/sugestions, i solved the problem.
asim
Dude you never posted the script which got you what you needed, may be someone searching the same thing would come here and get it... so please i request you to do it....
Related topics
10 Reasons to Date a Hockey Player
FTP - file last modified date
keep your adblocking up to date
When dating a new girl, how long do you wait before you kiss
PHP date() format for atom in php 4
A ActionScript,showing a running date.
Quels sous-forums aimeriez-vous avoir??
Date wrong on pc
Guess the Windows Vista Launch Date(Win Prizes!!!!)
Ten reasons you should date a geek
Is there a release date for ET:QW
mySQL - Day, date, month, year, time Output/Input
What date format do you prefere with MySQL?
date() function
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.