Jump to content

facun

New Members
  • Posts

    3
  • Joined

  • Last visited

facun's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried to convert Spanish date string into unix timestamp this way, but I guess I'm missing something: private function save_timestamp() { $date_flag = false; setlocale(LC_ALL,"es_ES"); $date = DateTime::createFromFormat("D, M d, Y g:ia", $this->date); if( $date["error_count"] == 0 && checkdate( $date["month"], $date["day"], $date["year"] ) ) $date_flag = true; if( $date_flag ) { $timestamp = $date->getTimestamp(); } else { $event_unix = get_post_meta( $this->post_id, 'event-unix', true ); if( ! empty( $event_unix ) ) $timestamp = $event_unix; else $timestamp = current_time( 'timestamp' ); } update_post_meta( $this->post_id, 'event-unix', $timestamp ); } $timestamp = $date->getTimestamp() may not be working.
  2. Hi, requinix. Thanks for the response. My guess is that $this->date refers to this object: /** * this global is only used for this template * profile-events-create.php */ global $pp_ec; $pp_ec = new PP_Simple_Events_Create(); Then, in profile-events-create.php there's an input to set the event date: <input type="text" id="event-date" name="event-date" placeholder="<?php echo __( 'Click to add Start Date...', 'bp-simple-events' ); ?>" value="<?php echo $pp_ec->date; ?>" /> And this is the correspondent js for the above input: $('#event-date').datetimepicker({ controlType: 'select', oneLine: true, dateFormat: 'DD, MM d, yy' }); Everything works as it should until you translate the date picker as posted above -> $.datepicker.setDefaults($.datepicker.regional['es']);
  3. Hello, I purchased a WP events plugin for a project and translated everything into Spanish, but I have a problem with unix timestamps as they're based on strtotime() which only accepts English strings. This is the function that generates the event timestamp: private function save_timestamp() { $date_flag = false; $date = date_parse( $this->date ); if( $date["error_count"] == 0 && checkdate( $date["month"], $date["day"], $date["year"] ) ) $date_flag = true; if( $date_flag ) { $timestamp = strtotime( $this->date ); } else { $event_unix = get_post_meta( $this->post_id, 'event-unix', true ); if( ! empty( $event_unix ) ) $timestamp = $event_unix; else $timestamp = current_time( 'timestamp' ); } update_post_meta( $this->post_id, 'event-unix', $timestamp ); } So, being the datepicker in Spanish, events are getting current dates (event creation date). The web is full of documentation about displaying unix dates in other languages, but I've not been able to find anything that does the opposite. I tried putting setlocale(LC_TIME, "es_ES") into the above function... I guess this is not the way to go. This is what I'm using to translate the jquery datepicker (as you can see I did not event tried to change the dateformat, just the texts so users understand what they're doing): $.datepicker.regional['es'] = { closeText: "Cerrar", // Display text for close link prevText: "Anterior", // Display text for previous month link nextText: "Siguiente", // Display text for next month link currentText: "Hoy", // Display text for current month link monthNames: ["Enero","Febrero","Marzo","Abril","Mayo","Junio", "Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"], // Names of months for drop-down and formatting monthNamesShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"], // For formatting dayNames: ["Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"], // For formatting dayNamesShort: ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab"], // For formatting dayNamesMin: ["Do","Lu","Ma","Mi","Ju","Vi","Sa"], // Column headings for days starting at Sunday //weekHeader: "Sm", // Column header for week of the year //dateFormat: "mm/dd/yy", // See format options on parseDate //firstDay: 1, // The first day of the week, Sun = 0, Mon = 1, ... //isRTL: false, // True if right-to-left language, false if left-to-right //showMonthAfterYear: false, // True if the year select precedes month, false for month then year //yearSuffix: "" // Additional text to append to the year in the month headers }; $.datepicker.setDefaults($.datepicker.regional['es']); Any help would be greatly appreciated.
×
×
  • 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.