Log in

View Full Version : How to display proper date on external website


pete_k104
12-31-2006, 05:13 PM
Hello!

I've been working on getting a simple news display script to properly display the time, but to not avail. I'm getting December 31, 1969 (UNIX epoch - 1).

I'm doing a simple script that's just pulling all the newest entries in the thread table. It's getting the userid from the post table, and is displaying a custom field I made (that is meant for full/real name) from the userfield table (field5).

The code worked perfectly fine with a vbb 3.5.4 installation, and I see no difference between the two, other than mysql table structure. Dateline is the same entity in both 3.5.x and 3.6.x

I was decoding it using

$date = date("m, d, Y", $date);

in each array object using the posts -> dateline value to show the date of the post. Dateline is stored as unixtime, based on the original Unix Epoch.

$date would be called in my array as

$date = $line['dateline'];Now, I've tried just making a bare script to take a dateline i feed it from the url to even test the date, and still no go.

I'm 100% sure it's not the server time, as I can successfully use

date("m d Y");I can also successfully feed it a dateline from vbb 3.5.4 and have a successful date echo.

My best guess is that date() cannot do the math properly against the unix epoch, and it is returning as -1, hence December 31, 1969. The reason why? My best guess is that vbb 3.6 stores dateline in a new format that date() cannot properly read.

Is my guess correct in saying that I must add a mathematical formula to have date() properly do the math against the epoch?

Guest190829
12-31-2006, 05:52 PM
You are looking for the vbdate function.


string vbdate (string $format, [integer $timestamp = TIMENOW], [boolean $doyestoday = false], [boolean $locale = true], [boolean $adjust = true], [boolean $gmdate = false])


You can find more detail in the api at:

http://members.vbulletin.com/api/

pete_k104
01-01-2007, 12:48 AM
Tried that this time around, and now it's giving me the unix epoch; January 1, 1970.

VBB is working just fine, though.

This is a mystery to me. Is there something between vbdate and the output of the formatted date in vbulletin that properly calculates the format?

include('mysql.php');
require_once('./global.php');
echo vbdate("m, d, Y", $timestamp, false, false, false, true);

$timestamp is being called from the url as date.php?timestamp

------------

EDIT : Close this thread, I feel like a total idiot. I hadn't been properly calling the timestamp. I needed a _GET[]. Silly me, i guess. All is working fine! Thanks.