Time / Date Handling

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Time / Date Handling

Post by thisbl00d »

im trying to build a script that keeps a Log of events. the log has the following fields

(postname, post_time , post_id)

when a post is made i call the function below

Code: Select all

function create_date()
{
    $today = date("D M d, Y H:i:s"); 
    $format = $today;
    return $format;
}
 
and then

Code: Select all

$post_time = create_date();
$post_time is inserted into MySql DataBase.

Now how shud i retrieve / display the post_time variable with the actual time of post ?
There is no need of TimeZone functionality for this script because the script will be used Locally only. Any suggestions or examples will be helpful
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Time / Date Handling

Post by pickle »

A simple SELECT sql statement will pull it back out. Maybe I'm missing the point of the post.

Why do you store the date in 2 separate variables in your create_date() function? It's completely unnecessary:

Code: Select all

function create_date(){
    return date("D M d, Y H:i:s"); 
}
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Re: Time / Date Handling

Post by thisbl00d »

:lol: i was trying some stuff with the code. removed a few lines between the 2 variables. anyway, my problem i solved myself
Post Reply