time and date function

Started on the old forum in August 2009 · view the original in the archive · old links redirect here

#date #error #function #php #time

11 replies · 867 views · started 17 years ago · 1 min read

4 participants
morse Senior · 364 posts #1

I have $a = day $b= month $c=year Now i want to show the date in the format $a $b $c How to use the time function? because when i echo "date($a $b $c)"; it gives me errors. How to echo it right?

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

subzero Super moderator Fellow · 3,954 posts #2
               $year = date("Y");
               $day = date("D");
               $mounth = date("M");
echo "$day,$mouth,$year";

$TimeZone="8"; ////Change the TimeZone accordingly! 
$New_Time = time() + ($TimeZone * 60 * 60); 
$show_time=date("H:i",$New_Time);  
$Hour=date("G",$New_Time); 

echo "<div>$show_time</div>"; 

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

morse Senior · 364 posts #3

That would just echo current date, current month and current year bro, i want to echo a specific date, month and time whose values are there in the $a , $b and $c variables

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

subzero Super moderator Fellow · 3,954 posts #4
               $date = date("a");
               $day = date("b");
               $mounth = date("c");

echo "<p class=\"sub\">© $day,$mounth,$date  $ctest</p>\n";

2009-08-13T01:49:05+09:30,am

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

CreativityKills Lead · 833 posts #5

morse wrote: That would just echo current date, current month and current year bro, i want to echo a specific date, month and time whose values are there in the $a , $b and $c variables

dude, the date() works with unix time stamp. So if u want 2 echo a specific dat, u'd avta knw its correct timestamp in seconds and do sumot like: echo date("d m y",$tmstamp);

NOTE: you can use strtotime() to convert string to time. Read php.net for more info. . .

morse Senior · 364 posts #6

Php does has a functionality to echo day, date, month and year in a specific format if we provide the variables correctly, but for some reason am unable to echo proper results, i end up echoing Wednesday 31st december for all the different variable values. I did read the manual and they havent explained php date and time functions that very well.

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

CreativityKills Lead · 833 posts #7

To undastand wot i sed earlyer i'l explain quickly d date function. It accepts 2 parameters. First, the format string, this tells the date function how to format the date its bring. The second parameter, this specifies the time u want to format in UNIX timestamp (seconds since 1, jan 1970, i guess) if left blank, date() uses d current date time stamp aka time() bt if u already ava date u want to output, just specify it as d 2nd parameter(in timestamp). U cud generate a timestamp urself.

$daysago = 20; //replace wit watever
$tmstmp = time() - ($daysago * 24 * 60 * 60);
echo date("d m y",$tmstmp);
morse Senior · 364 posts #8

maybe we both are not understanding each other, i can interpret what you meant by timestamp but it not an issue for me i just want

[COLOR=#000000][COLOR=#0000bb]date[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"l"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]mktime[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]7[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]2000[/COLOR][COLOR=#007700]))[/COLOR][/COLOR]

to work with my input variables, which for some unknown reason is not working and making me go nuts

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

morse Senior · 364 posts #10

a predicting sunday, monday, tuesday etc for somebodys forthcomming birthday

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

morse Senior · 364 posts #12

kiLLeR-eyEd_14 wrote: then add 1 day and 1day and 1 day

you are joking right?

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close