访问POST数据

I'm very new to PHP but have a good understanding of C,

When I want to access some post data on an API i'm creating in PHP I use:

 $_POST['date_set']

to fetch a value being passed for date - This all works perfectly, however I read I should be fetching it like this:

$date_set = trim(urldecode($_POST['date_set']));

This always returns a 00:00:00 value for the date after it's stored in my DB.

When I access directly using $_POST['date_set'] I get whatever value was posted, for example: 2013-08-28 10:31:03

Can someone tell me what I'm messing up?

You only run urldecode over data is URL encoded. PHP will have decoded it before populating $_POST, so you certainly shouldn't be using that. (You might have to if you are dealing with double-encoded data, but the right solution there should be to not double encode the data).

trim removes leading and trailing white-space. It is useful if you have a free form input in which rogue spaces might be typed. You will need to do further sanity checking afterwards.

You should try it like,

$date_set = $_POST['date_set'].explode(' ');//('2013-08-28 10:31:03').explode(' ')
echo $date_set[1];

or

echo date('H:i:s',strtotime($_POST['date_set'])));
//echo date('H:i:s',strtotime('2013-08-28 10:31:03'));

If you are very new in php the Read date()

urldecode — Decodes URL-encoded string

Description 
string urldecode ( string $str )
Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character. 

urldecode: is used only for GET requests. you should be fine using $_POST['date_set'] only.

http://php.net/manual/en/function.urldecode.php

You'd better do this way

if(isset($_POST['date_set'])){
 $date_set = $_POST['date_set'];
}

then you can use $date_set how you want. If you still get 00:00:00 for $date_set, the problem is coming from the code which provide you the $_POST value.