/    Sign up×
Community /Pin to ProfileBookmark

get the TIME off a SQL Database

I am attempting to grab the TIME and DATE a item was last modified in an SQL database, and I got the date part to work, but I am having one hell of a time getting the time to show up.

I keep getting a really long number, that seems like it’s the # of seconds since 1/1/1970. Yeah, I could care less about that. =)

Here’s a snippet of my code..

[CODE]
// Grab the time and date it was last modified
$query = “SELECT UNIX_TIMESTAMP() AS timestamp FROM merchant ;”;
$query2 = “SELECT UNIX_TIMESTAMP() AS timestamp FROM timestamp ;”;
$result = mysql_query($query);
$result2 = mysql_query($query2);
$row_date = mysql_fetch_array($result);
$row_time = mysql_fetch_array($result2);

// Now show it off…

echo “Rates are current as of “;
echo date(“m/d/y”, $row_date[‘timestamp’]);
echo ” at “;
echo time(“hh:mm:ss”, $row_time[‘timestamp’]);
//echo

[/CODE]

now, on the time echo, i was trying anything, so i’m pretty sure that’s wrong, but i was grabbing straws….

basically, there are records modified in a table called merchant, and i need to know when it was modified, and display it via php.

Any help is greatly appreciated!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 03.2006 — Just use the PHP date() function to output the time:
[code=php]
echo date("H:i:s", $row_time['timestamp']);
[/code]
Copy linkTweet thisAlerts:
@netboy541authorJun 03.2006 — yeah that's not working..

it's returning a Rates are current as of 69/12/31 - 19:00:00

i've been battling this for hours... i got it to give me the current date and time.. lol
×

Success!

Help @netboy541 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...