Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

showdate question

Asked Modified Viewed 2,253 times
M
maud138
M
  • Member, joined since
  • Contributed 64 posts on the community forums.
  • Started 23 threads in the forums
  • Started this discussions
asked
Member

Hi
I'm new to this.

Can somebody tell me why this isn't working?

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$result1 = dbquery("SELECT datumtijd FROM ".DB_SCORE." ORDER BY datumtijd DESC"wink;
$data1 =dbarray($result1);
$datum=showdate('longdate', $data1[1]);
echo "<div align='right' class='small'>".$datum."</div>\n";[/syntaxhighlighter]

datumtijd is a field in the database defined as timestamp
0 replies

7 posts

G
GMUDuckman
G
  • Senior Member, joined since
  • Contributed 266 posts on the community forums.
  • Started 6 threads in the forums
answered
Senior Member

try
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
$result1 = dbquery("SELECT datumtijd FROM ".DB_SCORE." ORDER BY datumtijd DESC"wink;
while($data1 =dbarray($result1)){
$datum=showdate('longdate', $data1["datumtijd"]);
}
echo "<div align='right' class='small'>".$datum."</div>\n";[/syntaxhighlighter]
Edited by GMUDuckman on 19-01-2011 23:29,
0 replies
M
maud138
M
  • Member, joined since
  • Contributed 64 posts on the community forums.
  • Started 23 threads in the forums
  • Started this discussions
answered
Member

Hi GMUDuckman,
The problem is that this code gives me 1 January 1970 01:33 and not the date that's in the Database. I checked this with phpmyadm. The date in the database is 2011-01-19 21:41:03
0 replies
M
MarcusG
M
Ex Senior Dev.
  • Member, joined since
  • Contributed 182 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

Then try this: [syntaxhighlighter brush=plain,first-line=1,highlight=0,collapse=false,html-script=false]$datum = $data1["datumtijd"][/syntaxhighlighter]

showdate() only works with UNIX timestamp.
0 replies
M
maud138
M
  • Member, joined since
  • Contributed 64 posts on the community forums.
  • Started 23 threads in the forums
  • Started this discussions
answered
Member

I really would like to use showdate().
datumtijd is a timestamp-type in the database. I use now() to get the date and time into the database. I guess it should work, but it doesn't.
Any ideas?
0 replies
M
MarcusG
M
Ex Senior Dev.
  • Member, joined since
  • Contributed 182 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

What is the type of the database field? If you use any kind of date as field type, the date will not be saved as a timestamp. Change it to INT(10), and showdate will work.
0 replies
M
maud138
M
  • Member, joined since
  • Contributed 64 posts on the community forums.
  • Started 23 threads in the forums
  • Started this discussions
answered
Member

I changed it to INT(10) and now I still get: 01 January 1970 1:33
When I look in the database the datumtijd-field is filled with only 2011.
0 replies
M
maud138
M
  • Member, joined since
  • Contributed 64 posts on the community forums.
  • Started 23 threads in the forums
  • Started this discussions
answered
Member

I got it!

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$result1 = dbquery("SELECT UNIX_TIMESTAMP(datumtijd) AS unix_date FROM ".DB_SCORE." ORDER BY datumtijd DESC"wink;
while($data1 =dbarray($result1)) {
$datum=showdate('longdate', $data1['unix_date']);}
echo "<div align='right' class='small'>".$datum."</div>\n";[/syntaxhighlighter]

Fieldtype of datumtijd is TIMESTAMP.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 7 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

G
G
  • Senior Member, joined since
  • Contributed 266 posts on the community forums.
  • Started 6 threads in the forums
M
M
  • Member, joined since
  • Contributed 64 posts on the community forums.
  • Started 23 threads in the forums
  • Started this discussions
M
M
Ex Senior Dev.
  • Member, joined since
  • Contributed 182 posts on the community forums.
  • Started 5 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet