vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Date Format Question (https://vborg.vbsupport.ru/showthread.php?t=37609)

MarkB 04-18-2002 11:39 PM

Date Format Question
 
I'm using the snippet of code Freddie posted here to get the date format:

Code:

SELECT DATE_FORMAT(eventdate,'%b-%d') AS eventdate
It outputs the date as (eg) Apr-18

Can I make it display as April-18 (ie, full month name)?

Neo 04-19-2002 12:08 AM

Instead of %b use %M

MarkB 04-19-2002 12:32 AM

Thanks neo :)

Now another question. I have this code:

Code:

<?PHP
require("./global.php");
$events = $DB_site->query("SELECT eventid, DATE_FORMAT(eventdate,'%M %d') AS eventdate, subject, venue, location FROM calendar_events WHERE public='1' ORDER BY eventdate LIMIT 10");
while ($event = $DB_site->fetch_array($events)) {
 echo "<font size=1 face=\"verdana, helvetica\">" . $event['eventdate'] . " <a href=\"$bburl/calendar.php?s=&action=getinfo&eventid=" . $event['eventid'] . "\">" . $event['subject'] . "</a> " . $event['location'] . "</font>";
}
?>

It spits out the dates fine, but since I have it ordered by date, it lists the months alphabetically instead of by calendar order... Is there a way to fix that? :ermm:

MarkB 04-19-2002 12:44 AM

You can see the output here:

http://www.ultimatemetal.com/forum/events2.php

Neo 04-19-2002 12:46 AM

There are two ways I know of doing it. Either add another row like "monthnum" and sort by that or, change the %M so that it reads in the date like 0-5-3 and then use MONTHNAME which would output May.

MarkB 04-19-2002 12:52 AM

:ermm:

Where would I put MONTHNAME?

Neo 04-19-2002 01:22 AM

Hmm well it would have to be in a different query maybe. BUt your best shot as far as I know would tp just enter the month number aswell for sorting purposes.

MarkB 04-19-2002 01:45 AM

I worked it out - thanks for pointing me in the right direction :) I changed the code to:

SELECT eventid, DATE_FORMAT(eventdate,'%M %d') AS date, eventdate, ...

And then just changed the later $event['eventdate'] to $event['date'] - so, it lists the month but sorts by the correct date :)

Thanks Neo :D

MarkB 04-19-2002 01:46 AM

Now to try and find out how to make each row have an alternating background colour (like the posts in showthread) :)

Neo 04-19-2002 01:55 AM

Well have fun :)
I am off the the old sleep

MarkB 04-19-2002 01:58 AM

Thanks again :)

EZwriter 10-07-2002 04:37 PM

Hi,

I'm having a bit of trouble with formatting the date from the thread table. I am getting NULL as a result from this query:

PHP Code:

select date_format(lastpost'%y-%m-%d') as formatted_date from thread limit 10

Anyone know what's up?

EZwriter 10-07-2002 05:26 PM

Never mind...

FWIW, instead of using DATE_FORMAT, the correct option is to use FROM_UNIXTIME.

:rambo:


All times are GMT. The time now is 01:09 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.01154 seconds
  • Memory Usage 1,734KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (13)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete