Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

the name of the day

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

the name of the day

Postby rafaes18 » Thu Oct 24, 2002 1:20 am

Hi There how could I get the name of the day (for example wednesday or thursday) for a given date (for example 2002-10-25) thank you
rafael
rafaes18
New php-forum User
New php-forum User
 
Posts: 13
Joined: Thu Sep 12, 2002 7:18 am

Postby Jay » Thu Oct 24, 2002 1:49 am

You will need to use the date() function! Have a look at the manual for full use of it
Jay
 

Postby rafaes18 » Thu Oct 24, 2002 3:09 am

I know the date() function but still is not what I need.
If I say date(l) I would get Thursday which is the name of todays day of the week. What I need to do is to give this function a year, month and number of the day of the month to return the name of the week belonging to that date.
thanks
rafa
rafaes18
New php-forum User
New php-forum User
 
Posts: 13
Joined: Thu Sep 12, 2002 7:18 am

Postby rafaes18 » Thu Oct 24, 2002 3:50 am

I got it all I need to do is
echo date ("l", mktime (0,0,0,$Month,$Day,$Year));
if for example $date was
$date="03-03-2002";
I have to explode this variable
$var = explode ("-",$date);
$Month = $var[0];
$Day = $var[1];
$Year = $var[2];
using
echo date ("l", mktime (0,0,0,$Month,$Day,$Year));
I'll get the name of the day of the week for that date.
rafaes18
New php-forum User
New php-forum User
 
Posts: 13
Joined: Thu Sep 12, 2002 7:18 am

Postby Jay » Thu Oct 24, 2002 6:58 am

Well done, you can also do date("l",strtotime("1st September 2002"));
Jay
 

Postby DoppyNL » Fri Oct 25, 2002 2:13 am

Jay wrote:Well done, you can also do date("l",strtotime("1st September 2002"));

but note that the strototime function only accepts english dates!
When supplying a date in a different language it will fail.

If you want to display a date (or part of it) in a particular language, take a look at the function setlocale and click from there to other functions related to it.

Greetz Daan
DoppyNL
 


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron