vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   date blues (https://vborg.vbsupport.ru/showthread.php?t=55421)

Dave# 07-19-2003 02:00 PM

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

Gary King 07-19-2003 02:40 PM

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>";
?>


Dave# 07-19-2003 02:53 PM

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

Gary King 07-19-2003 04:45 PM

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>";
?>


Dave# 07-19-2003 08:24 PM

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

Velocd 07-19-2003 09:26 PM

<a href="http://us4.php.net/manual/en/function.date.php" target="_blank">http://us4.php.net/manual/en/function.date.php</a>

Gary King 07-19-2003 10:34 PM

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.

Dave# 07-20-2003 07:01 PM

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

Gary King 07-20-2003 07:22 PM

Glad I could help :)

Dave# 07-24-2003 05:13 PM

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

http://www.cpfc.org/fixtures/


All times are GMT. The time now is 02:29 PM.

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.01061 seconds
  • Memory Usage 1,780KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete