What data types should I use to store in MySQL phone (79991112233), time in timestamp format?

  • varchar text field - Jean-Claude

2 answers 2

INT for timestamp and if you plan to use only the number for storing the phone then BIGINT , if you use the + , ( , ) symbols, that is, the phone is in string format, then VARCHAR

    Text (varchar (20)) is most often used for a telephone, since it is not known in what format it will be necessary to store the telephone in the future. At the same time, it will be necessary to impose restrictions on the phone format with a regular form on the phone input form (js input mask) and on the php side in form processing. So it will be the safest of all and it will not be necessary to convert each time when reading from the database.

    • In the "numbers only" format, the maximum MSISDN length is set to 15 digits. - etki