ok here is the problem
I have 3 numbers for hour, day, and month
example:
$aud1hour = "09";
$aud1day = "15";
$aud1month = "10";
basically meaning 9:00am, Oct, 15th
whats the easiest way to take those varibles and convert them to this format with the least amount of code, even if the varibles chage, i need a function that converts it quickly.
remember the format must be:
hour, Month, Day like: 9:00am, Oct, 15th
convert 3 variables into timestamp format
Moderator: General Moderators
-
chrismicro
- Forum Newbie
- Posts: 21
- Joined: Fri Nov 12, 2010 7:03 am
-
chrismicro
- Forum Newbie
- Posts: 21
- Joined: Fri Nov 12, 2010 7:03 am
Re: convert 3 variables into timestamp format
this still has issues:
the hour format is 00 -23
the day format is 0-31
month format is from 01-12
$aud1hour = "00";
$aud1day = "20";
$aud1month = "09";
$hour = date('GA',mktime($aud1hour));
$month = date('F',mktime($aud1month));
$day = date('jS',mktime($aud1day));
echo "<font face='geneva, arial, sans serif' size='2' color='#00FF00'>".$month.", ".$day." - ".$hour."</font>";
will show:
January, 6th - 0AM...weird..any help would be great, make note the month day hour are the only variables i have to work with
the hour format is 00 -23
the day format is 0-31
month format is from 01-12
$aud1hour = "00";
$aud1day = "20";
$aud1month = "09";
$hour = date('GA',mktime($aud1hour));
$month = date('F',mktime($aud1month));
$day = date('jS',mktime($aud1day));
echo "<font face='geneva, arial, sans serif' size='2' color='#00FF00'>".$month.", ".$day." - ".$hour."</font>";
will show:
January, 6th - 0AM...weird..any help would be great, make note the month day hour are the only variables i have to work with
Last edited by chrismicro on Thu Jan 06, 2011 1:00 am, edited 2 times in total.
-
thecodewall
- Forum Commoner
- Posts: 33
- Joined: Sun Dec 26, 2010 8:37 am
Re: convert 3 variables into timestamp format
Maybe this can help.
From my program:
http://codewall.blogspot.com
From my program:
Code: Select all
$day = $_POST['expiry_date_day'];
$month = $_POST['expiry_date_month'];
$year = $_POST['expiry_date_year'];
$date = date('Y-m-d',strtotime($year.'-'.$month.'-'.$day));
$query="INSERT INTO stock (code, name, expirydate, category, count)
VALUES('$_POST[code]','$_POST[name]','$date','$_POST[category]','$_POST[count]')";
mysql_query($query) or die(mysql_error());
Re: convert 3 variables into timestamp format
Look up how mktime() is used. It expects 6 parameters, not just one. You likely want something like this:
Code: Select all
$stamp = mktime(0,0,0,$aud1month,$aud1day,date('Y'));
$formatted_date = date('g:ia, M jS',$stamp);Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
chrismicro
- Forum Newbie
- Posts: 21
- Joined: Fri Nov 12, 2010 7:03 am
Re: convert 3 variables into timestamp format
This worked:
$stamp = mktime($aud1hour,0,0,$aud1month,$aud1day,0);
$formatted_date = date('g:ia, M jS',$stamp);
Thanks for all your help guys
$stamp = mktime($aud1hour,0,0,$aud1month,$aud1day,0);
$formatted_date = date('g:ia, M jS',$stamp);
Thanks for all your help guys