Title: csv time format and import time format different causing issues
Last modified: October 5, 2019

---

# csv time format and import time format different causing issues

 *  Resolved [marinersspace](https://wordpress.org/support/users/marinersspace/)
 * (@marinersspace)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/csv-time-format-and-import-time-format-different-causing-issues/)
 * I have a csv file showing date as “YYYY-mm-dd hh:mm:ss” or “None”
    But for import
   I need time format as mm/dd/YYYY hh:mm AM/PM
 * I am not that good with coding skills but managed to make a small change date
   function program would like to get input for the function or even suggestions
   if you can.
 *     ```
       function change_date ($date_end) {
       	if ($date_end=="None"){
       		echo "12/31/2019";
       	}
       	else{
       	echo date_format($date_end,'m/d/Y H:i A');
       	}
       }
       ```
   
 * hope my program makes some sense to you.
    The program sometime worked on the 
   localhost but failed on the live server.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/csv-time-format-and-import-time-format-different-causing-issues/#post-12010269)
 * Hi [@marinersspace](https://wordpress.org/support/users/marinersspace/)
 * > But for import I need time format as mm/dd/YYYY hh:mm AM/PM
 * Here’s an example function you can use:
 *     ```
       function my_fix_date( $date = '', $format = 'Ymd', $new_format = 'Y/m/d' ) {
       	if ( empty( $date ) || $date == 'None' ) return "12/31/2019";
   
       	if ( $obj = DateTime::createFromFormat( $format, $date ) ) {
       		return $obj->format( $new_format );	
       	} else {
       		return null;
           }
       }
       ```
   
 * Example usage:
 * `[my_fix_date({date[1]},"Y-m-d H:i:s","m/d/Y H:i A")]`
 * Just change {date[1]} to the import element from your file that contains the 
   date.
    -  This reply was modified 6 years, 8 months ago by [WP All Import](https://wordpress.org/support/users/wpallimport/).
 *  Thread Starter [marinersspace](https://wordpress.org/support/users/marinersspace/)
 * (@marinersspace)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/csv-time-format-and-import-time-format-different-causing-issues/#post-12011413)
 * Thank you for your quick response. This function has worked properly. It has 
   even helped me resolve the technical issues arising due to my theme not fully
   compatible with your plugin.
    Thank you for your support.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘csv time format and import time format different causing issues’ is closed
to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [date format](https://wordpress.org/support/topic-tag/date-format/)

 * 2 replies
 * 2 participants
 * Last reply from: [marinersspace](https://wordpress.org/support/users/marinersspace/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/csv-time-format-and-import-time-format-different-causing-issues/#post-12011413)
 * Status: resolved