/    Sign up×
Community /Pin to ProfileBookmark

Converting mySQL timestamp into a useable date

Hi,

I’m trying to extract the timestamp in a mySQL file and display it as a real date/time.

Here’s what I’ve got…

$rsi = mysql_query($qri, $link);
$rwi = mysql_fetch_array($rsi);

$stamp = $rwi[‘FIstamp’];
$dte = strtotime($stamp);

$showdate = date(“F d, Y H:i”,$dte);

It returns $dte = -1, which, of course, then displays as a date in 1969 (the first possible date)

If I skip the strtotime() function, and try to make $showdate using $stamp, i get a date in 2038, the last possible date.

Now I’m clueless. (Perhaps I always was.)

Help much appreciated, as always.

Thanks
CTB

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@chestertbauthorApr 28.2005 — Thanks Pyro...

But I'm not sure I'm getting it.

The mySQL timestamp is stored as an integer, in this case, 20050428042656, which looks like made up of the elements of the date time... 2005 04 28 04 26 56

I would have thought there would have been a simple way to convert that into something more useable, but if I interpret your post correctly, I need to break it up, and re-assemble it. Is that correct?

Thanks

CTB
×

Success!

Help @chestertb 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.28,
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,
)...