Jump to content

Archived

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

lildog

php date question

Recommended Posts

I hope someone can shed some light on something for me. I put a snippet of code below. If a checkbox(today_date) is checked I want the current date put into $ustamp, when I echo ustamp or try to compare it to another date variable it is empty. BUT when I insert it into my DB it puts the correct date. So it appears to be a null variable but it is not......

 

 

if ($HTTP_POST_VARS['today_date']){

$utstamp =date("Y-m-d H:M:S");

}

 

Thanks for any help or pointers,

lildog

Share this post


Link to post
Share on other sites
I hope someone can shed some light on something for me. I put a snippet of code below. If a checkbox(today_date) is checked I want the current date put into $ustamp, when I echo ustamp or try to compare it to another date variable it is empty. BUT when I insert it into my DB it puts the correct date. So it appears to be a null variable but it is not......

 

 

if ($HTTP_POST_VARS['today_date']){

$utstamp =date("Y-m-d H:M:S");

}

 

Thanks for any help or pointers,

lildog

 

Well date("Y-m-d H:M:S"); is wrong for starters.

 

example: date("Y-m-d H:i:s");

Share this post


Link to post
Share on other sites

Thank you,

That is much better, I also left a character out of the variable when checking it. Stupid mistake. Your advice led me there.

 

Thanks a bunch,

lildog

Share this post


Link to post
Share on other sites

If you browse the php.net site, you can find all kinds of good info about the date(), strtotime(), and other date/time related functions, and you will find that other people have already done most of the work for you in the examples underneath the description of each function.


No Links To My Website Here!

Share this post


Link to post
Share on other sites

×