Jump to content

[SOLVED] Inserting date into mysql?


JP128

Recommended Posts

Ok, here is all the info...

the column join date is a timestamp.
I insert into that column with a mysql_query, and the now() function.
when I call that date, and try to format it into m/d/Y h:i:s ... it always comes out Dec, 31 1969 4:33:26 PM...
Link to comment
Share on other sites

Something that I found on the internet...

POST:
LOL - it says "Googlebot last successfully accessed your home page on Dec 31, 1969" - does that make my site on of the oldest on the net? :)

REPLY
Actually, that date occurs when a timestamp isn't valid...looks like a possible but in the code. ;)
Link to comment
Share on other sites

When you use the date() function to format the display of a date and/or time in php, the specified date/time should be in a timestamp format, not as returned from the mysql database.  A timestamp is an int that represents the number of seconds passed since the epoch (01 Jan 1970).

To use the date() function you should convert your returned datetime valye from mysql using the strtotime() function.

try this:

<?php

$time = strtotime($row['joined_date']);
$newTime = date("m/d/Y h:i:s",$time);

?>
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.