Jump to content

PHP mysql time


Pain

Recommended Posts

Hi guys.

 

I want to make two records.

 

1)Current time and date.

2)Time and date after 20 seconds.

 

Now i have this piece of code:

<?php
$hr  = 0;
$min = 0;
$sec = 11;

echo $date = date("Y-m-d H:i:s");echo "\n";
echo $modified = time() + (0 * 0 * 0 * 20);

?>

 

I think there is something wrong with this line:

<?php
echo $modified = time() + (0 * 0 * 0 * 20);1
?>

I get something like this: 1324668576.

 

You can check this http://kingstonuni.atspace.co.uk/RPG/muziejus.php link to get a better view.

 

Any help would be appreciated. Thank you.

 

 

 

 

Link to comment
Share on other sites

time - "Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)."

 

The integer you're getting is actually correct in seconds.  If you're trying to store this in MySQL then why not use NOW() when inserting into the DB?

Link to comment
Share on other sites

Looks like that works, but the output is still in this format 1324670946.

I need it to be like this: 2011-12-23 20:08:46.

I think you're performing too many steps, something like this should suffice:

echo date('Y-m-d h:i:s', strtotime("+20 seconds"));

Link to comment
Share on other sites

Looks like that works, but the output is still in this format 1324670946.

I need it to be like this: 2011-12-23 20:08:46.

I think you're performing too many steps, something like this should suffice:

echo date('Y-m-d h:i:s', strtotime("+20 seconds"));

This is what i was searching for! Thank you!

Link to comment
Share on other sites

how can i retrieve timestamp from the db?:/

As Pikachu said, show us the code you're trying to use along with errors.  If you don't have code I would suggest Googling it, making an attempt, and coming back to specific help.  There are a multitude of good examples.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.