evDateToSQL | returns an SQL formated date from a given date


/ Published in: PHP
Save to your folder(s)

you can specify the source date format with the third parameter


Copy this code and paste it in your HTML
  1. // name: evDateToSQL
  2. // version: v0.1
  3. // description: devuelve un string para sql
  4.  
  5. function evDateToSQL( $date, $separator = '/', $lang = null ) {
  6. $dateTemp = explode( $separator, $date );
  7. switch ( $lang ) :
  8. case 'es' :
  9. $dateConv = $dateTemp[2] . '-' . $dateTemp[1] . '-' . $dateTemp[0];
  10. break
  11. default :
  12. $dateConv = $dateTemp[2] . '-' . $dateTemp[0] . '-' . $dateTemp[1];
  13. break
  14. endswitch;
  15. return $dateConv;
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.