Page 1 of 1
Strip Date() to Days, Hours, Min, Sec
Posted: Tue Mar 09, 2010 3:07 pm
by Goofan
Hi i would like to strip a Date() so that i can get the day,Hour, Min, Sec format into a variable called $day, $Hour, $Min, $Sec.
Only problem i got is i dont know really how to strip it into parts and put the selected parts into variables.
//Thanks in advance
//Thomas
Re: Strip Date() to Days, Hours, Min, Sec
Posted: Tue Mar 09, 2010 4:01 pm
by akuji36
Re: Strip Date() to Days, Hours, Min, Sec
Posted: Tue Mar 09, 2010 4:09 pm
by Goofan
Well i didnt understand alot about that so correct me if it where what i were looking for.
But ill try explaining again.
$time=date(day, hour, min, sec);
(strip ($time)) //somehow...
get the days, hours, min and sec as following:
Put the value of Days into variable $Day
Put the value of Hours into variable $Hour
Put the value of Mins into variable $Min
Put the value of Secs into variable $Sec
so that i can use the variables.
//Thanks in advance
//Thomas
Re: Strip Date() to Days, Hours, Min, Sec
Posted: Tue Mar 09, 2010 4:52 pm
by pickle
Code: Select all
list($day,$month,$year,$hour,$minutes,$seconds) = explode('/',date('d/m/y/h/i/s'));
Re: Strip Date() to Days, Hours, Min, Sec
Posted: Wed Mar 10, 2010 8:57 am
by akuji36
You want something like this:
Code: Select all
<?php echo date("l"); ?>  
<?php echo date("F j, Y"); ?>  
<?php
echo date("h:i:s a");
?>
Using the php date function:
l = Day of the week
F= Month
j= day of month in number format: example 1st, 2nd, or 24 day of month
Y= year
h= hour
i=minutes
s=seconds
a= Am or Pm
the ":" are for formatting purposes.
Find more on use of the date function here:
http://php.about.com/od/learnphp/ss/php_functions_3.htm
thanks
Rod
Re: Strip Date() to Days, Hours, Min, Sec
Posted: Wed Mar 10, 2010 9:01 am
by Goofan
Hi rod!
Well not exacly... but the basics is correct i wanted those l m y and such as into variables...
so that the l m y and such as becomes $l $m $y... =)
Re: Strip Date() to Days, Hours, Min, Sec
Posted: Wed Mar 10, 2010 9:07 am
by Goofan
ohh sorry Rod didnt see pickle wrote
Pickle u found what i were looking for thank you so much!