In the database table there is a field of type (datetime).

When adding data there you need to record the current date and time.

If via php write in this form:

date("mdy H:i:s "); 

then this format is suitable for the database? or need to convert it like that?

  • It is clear ... gentlemen "programmers" - vasyavasya
  • 3
    > Clearly ... gentlemen "programmers" @VasyaVasya what kind of battlethur? Do you really think that any person, barely seeing your question, is immediately obliged to give up everything and begin to answer it? - DreamChild
  • one
    @VasyaVasya 1. use standard Ymd H:i:s , I just can’t guarantee the rest, because I don’t use it as unnecessary 2. mysql default datetime format is googled in three seconds and don’t even have to start about English - YYYY-MM- The DD is clear without it. 3. What prevents you from just trying? - etki
  • I would recommend TIMESTAMP, and in the output convert as you wish - MDJHD

2 answers 2

Use the timestamp format, it is much more convenient when used further.

Two times

  • one
    I agree. all arms and legs for timestamp - mountpoint

This is also possible

 $dates =date('Ymd H:i:s', strtotime('2010-10-12 15:09:00') ); $query = "INSERT INTO timeTable(time) VALUES ('$dates')";