Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2003, 02:00 PM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default date blues

I have a script that pulls the latest eventd from my VB, the problem is that the date gets pulled in American rather than European format:

PHP Code:
<?php

include('../global.php');

$events $DB_site->query("SELECT event, eventdate, eventid, subject
                           FROM calendar_events
                           WHERE public = 1 AND eventdate >= NOW()
                           ORDER BY eventdate LIMIT 8"
);
if (
$DB_site->num_rows($events)) {
  echo 
"<ul>";
  while (
$event $DB_site->fetch_array($events)) {
    echo 
"<li><font size=\"1\">".$event['eventdate']." <a
href='calendar.php?s=
$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a> <br>
        "
;
  }
} else {
  echo 
"No Events";
}
echo 
"</ul>";
?>
anyone help me get the date in European Format?

dd-mm-yy

TIA
Reply With Quote
  #2  
Old 07-19-2003, 02:40 PM
Gary King's Avatar
Gary King Gary King is offline
 
Join Date: Jan 2002
Posts: 2,046
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php

include('../global.php');

$events $DB_site->query("SELECT event, eventdate, eventid, subject
                           FROM calendar_events
                           WHERE public = 1 AND eventdate >= NOW()
                           ORDER BY eventdate LIMIT 8"
);
if (
$DB_site->num_rows($events)) {
  echo 
"<ul>";
  while (
$event $DB_site->fetch_array($events)) {
        list(
$year,$month,$day)=split("-",$event['eventdate']);
    echo 
"<li><font size=\"1\">$day-$month-$year <a
href='calendar.php?s=
$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a> <br>
        "
;
  }
} else {
  echo 
"No Events";
}
echo 
"</ul>";
?>
Reply With Quote
  #3  
Old 07-19-2003, 02:53 PM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Gary -

I ended up doing it like this:

PHP Code:
<?php

include('../global.php');

$events $DB_site->query("SELECT event, DATE_FORMAT(eventdate,'%d %M') AS date, eventdate, eventid, subject
                           FROM calendar_events
                           WHERE public = 1 AND eventdate >= NOW()
                           ORDER BY eventdate LIMIT 8"
);
if (
$DB_site->num_rows($events)) {
  echo 
"<ul>";
  while (
$event $DB_site->fetch_array($events)) {
    echo 
"<li><font size=\"1\">".$event['date']." <a
href='calendar.php?s=
$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a> <br>
        "
;
  }
} else {
  echo 
"No Events";
}
echo 
"</ul>";
?>
The only problem with this is I can't seem to change the date format to support the actual day - like Friday 13th September

cheers

Dave
Reply With Quote
  #4  
Old 07-19-2003, 04:45 PM
Gary King's Avatar
Gary King Gary King is offline
 
Join Date: Jan 2002
Posts: 2,046
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here you go
I changed include() to require(), you should use require instead of include, because the script becomes useless if it can't include the global.php
Only use include() if the script can still execute without including the file.

PHP Code:
<?php

require('../global.php');

$events $DB_site->query("SELECT event, DATE_FORMAT(eventdate,'%d %M') AS date, eventdate, eventid, subject
                           FROM calendar_events
                           WHERE public = 1 AND eventdate >= NOW()
                           ORDER BY eventdate LIMIT 8"
);
if (
$DB_site->num_rows($events)) {
  echo 
"<ul>";
  while (
$event $DB_site->fetch_array($events)) {
        
$timestring=strtotime($event['date']);
        
$date=date("l jS F",$timestring);
    echo 
"<li><font size=\"1\">".$date." <a
href='calendar.php?s=
$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a> <br>
        "
;
  }
} else {
  echo 
"No Events";
}
echo 
"</ul>";
?>
Reply With Quote
  #5  
Old 07-19-2003, 08:24 PM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 06:45 PM Gary W said this in Post #4
Here you go
I changed include() to require(), you should use require instead of include, because the script becomes useless if it can't include the global.php
Only use include() if the script can still execute without including the file.

PHP Code:
<?php

require('../global.php');

$events $DB_site->query("SELECT event, DATE_FORMAT(eventdate,'%d %M') AS date, eventdate, eventid, subject
                           FROM calendar_events
                           WHERE public = 1 AND eventdate >= NOW()
                           ORDER BY eventdate LIMIT 8"
);
if (
$DB_site->num_rows($events)) {
  echo 
"<ul>";
  while (
$event $DB_site->fetch_array($events)) {
        
$timestring=strtotime($event['date']);
        
$date=date("l jS F",$timestring);
    echo 
"<li><font size=\"1\">".$date." <a
href='calendar.php?s=
$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a> <br>
        "
;
  }
} else {
  echo 
"No Events";
}
echo 
"</ul>";
?>
This gives me the date like

2003-07-23

Rather than

Friday 23rd June

Dave
Reply With Quote
  #6  
Old 07-19-2003, 09:26 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://us4.php.net/manual/en/function.date.php" target="_blank">http://us4.php.net/manual/en/function.date.php</a>
Reply With Quote
  #7  
Old 07-19-2003, 10:34 PM
Gary King's Avatar
Gary King Gary King is offline
 
Join Date: Jan 2002
Posts: 2,046
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 05:24 PM Dave# said this in Post #5
This gives me the date like

2003-07-23

Rather than

Friday 23rd June

Dave
Not for me.
Reply With Quote
  #8  
Old 07-20-2003, 07:01 PM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 12:34 AM Gary W said this in Post #7
Not for me.
must of done a typo first time - works great - sincere thanks

Dave
Reply With Quote
  #9  
Old 07-20-2003, 07:22 PM
Gary King's Avatar
Gary King Gary King is offline
 
Join Date: Jan 2002
Posts: 2,046
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad I could help
Reply With Quote
  #10  
Old 07-24-2003, 05:13 PM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Gary - any idea why the code would give the icorrect day for dates in 2004?

http://www.cpfc.org/fixtures/
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:15 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07345 seconds
  • Memory Usage 2,290KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete