Jump to content

strotime proper form


dadamssg

Recommended Posts

im trying to create a timestamp for a date...whats the proper format?

 

strtotime(2009-03-31 12:45:00); isn't working

 

im trying to create one from POSTs

 

example

 

$_SESSION['ends'] = $_POST['eyear']."-".$_POST['emonth']."-".$_POST['eday']."-".$ehour.":".$_POST['eminute'].":00";

$selected = strtotime($_SESSION['ends'];

 

i must be an idiot because i can't really get anything from the manual on this

 

and the $ehour = $_POST['ehour']+12; IF pm is selected

 

ive tried mktime and gmmktime but if i select certain times they are way off

 

Link to comment
https://forums.phpfreaks.com/topic/151878-strotime-proper-form/
Share on other sites

well i tried that but heres my code for that...the whole thing thats messing me up is the adding 12 if pm is selected

 

if pm is not selected

$_SESSION['ends'] = $_POST['eyear']."-".$_POST['emonth']."-".$_POST['eday']."- ".$_POST['ehour'].":".$_POST['eminute'].":00";

 

if it is

if($_POST['eampm'] == 'pm')
   {
     $ehour = $_POST['ehour'] + 12;

     $_SESSION['ends'] = $_POST['eyear']."-".$_POST['emonth']."-".$_POST['eday']."-".$ehour.":".$_POST['eminute'].":00";
      $end = gmmktime($ehour+5, $_POST['eminute'],0, $_POST['emonth'], $_POST['eday'], $_POST['eyear']);
   }
   else
   {
   $end = gmmktime($_POST['ehour']+ 5, $_POST['eminute'],0, $_POST['emonth'], $_POST['eday'], $_POST['eyear']);
   }

 

i did +5 for the ehour to get to my timezone

and i insert the $_SESSION['ends'] in my db...and its always correct, so i set up the $end=gmmktime() to check if the datetime they selected is before now...i don't want things in my db that have already ended. and it works for every time except for 12pm...if i select say march 31, 12pm it will say i selected april 1, 12am

 

so thats no good...

Link to comment
https://forums.phpfreaks.com/topic/151878-strotime-proper-form/#findComment-797561
Share on other sites

i tried this but its the same result...i think it will work but i dont think i have it properly set up in the if part...any help with that?

 

if($POST['eampm'] == 'pm' && $_POST['ehour'] = 12)
{
$ehour = 23;
$end = mktime($ehour, $_POST['eminute'],0, $_POST['emonth'], $_POST['eday'], $_POST['eyear']);
} 

 

i think its just skipping over it because its not setup right

Link to comment
https://forums.phpfreaks.com/topic/151878-strotime-proper-form/#findComment-797563
Share on other sites

Are you testng locally on your machine or using web space?

 

If web space, think where the server is hosting your web space and think if there's a time difference.

 

For example, I'm in the UK and my web space is in the US so my time functions always produce values way off to what I need.

 

I could use gmdate()...

Link to comment
https://forums.phpfreaks.com/topic/151878-strotime-proper-form/#findComment-797589
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.