Jump to content

Recommended Posts

Hi,

 

I need to extract the month number from a datetime field so that I can dynamically determine a graphic file name.

 

i currently have this in my html table:

<td VALIGN=top style=\"height:80; width:80;\"><img style=\"position:absolute; z-index:1;\" src=\"calpics/background.png\" height=\"79\" width=\"79\">
<img style=\"position:absolute; z-index:2;\" src=\"calpics/1.png\" height=\"79\" width=\"79\">
<img style=\"position:absolute; z-index:3;\" src=\"calpics/jan.png\" height=\"79\" width=\"79\"></td>".
"<td>{$row['gl_date']}</td>".

 

the top (left) TD builds the graphic, where I have "1.png" I'd like to determing the file name from the date.

 

for a starting point, i'd like to know how to display

{$row['gl_date']}

as just the month number.

Link to comment
https://forums.phpfreaks.com/topic/195681-format-date-coming-from-database/
Share on other sites

how is the date stored in db?

it in datetime format - so for "2010-12-04 00:00:00" I need to extract "12"

 

its more the sytax that i'm unsure of - i'm fairly new to php, but have been working with SQL for around eight years - just need a bit of guidance on how to make it work.

hi you can get using query itself, like this

 

select month(gl_date) from tablename;

 

why u going for php, if u still need in php,use the below code,

 

echo date('m',strtotime($row['gl_date'])); //with leader zeros, like, 03
or
echo date('n',strtotime($row['gl_date'])); //without leader zeros, like, 03

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.