Jump to content

date from timestamp


ramiwahdan

Recommended Posts

Hi,

I have a table field that has the full timestamp (date and time), I want to select records from DB but after checking the date part only from the timestamp.

Example:

2020-3-10 10:15:00 ---- i want to check if current date is equal to the date part which in this case it is the same.

Thanks.

Link to comment
Share on other sites

times.png.ae1ef302965cfececc8141210e192085.png

17 minutes ago, ramiwahdan said:

I tried this but it is not getting the date from the timestamp:


$testDate = date($row2['ClockingInDate']);
$curdate = date("Y-m-d");

I am still getting the full date and time for the first variable!

I tried a better one but i am getting the default value of 1970:

$testDate= date('Y-m-d',$row2['ClockingInDate']);
$curdate = date("Y-m-d");

testDate is getting the default value of 1970...why is that?

Edited by ramiwahdan
update with screen shot
Link to comment
Share on other sites

Show us your query.  The way I would do this would be to use a mysql function to only select the yyyy-mm-dd portion of the timestamp and compare it (in the where clause) to the exact yyyy-mm-dd value you want to find.  To be clear - I would do this IN the query statement itself.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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