Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

318
Vistas
¿Cómo puedo cambiar el formato de mi fecha dentro de mi secuencia de comandos? Me gustaría que muestre solo dd/mm/yyyy
function reminder() { var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet() var data = sh.getDataRange().getValues() var d = new Date().getTime(); for (var i=1;i<data.length;i++){ if (data[i][4]<=new Date(d+7*24*60*60*1000) && data[i][4]>=new Date(d+5*24*60*60*1000) && data[i][6]==''){ MailApp.sendEmail({to:data[i][3], subject: 'Reminder Process Update Required in 1 week', htmlBody: 'Hello '+data[i][1]+' The page for '+data[i][0]+' is due to review on '+data[i][4]+' Please review the content and contact the team before its due date if amendments are required.' }) sh.getRange(i+1,7).setValue('sent') } else if (data[i][4]<=new Date(d+30*24*60*60*1000) && data[i][4]>=new Date(d+28*24*60*60*1000) && data[i][5]==''){ MailApp.sendEmail({to:data[i][3], subject: 'Reminder Process Update Required in 1 month', htmlBody: 'Hello '+data[i][1]+' The page for '+data[i][0]+' is due to review on '+data[i][4]+' Please review the content and contact the team before its due date if amendments are required.' }) sh.getRange(i+1,6).setValue('sent') } } }

¿Cómo puedo cambiar el formato de la fecha en mi secuencia de comandos? Actualmente está generando un correo electrónico automático, sin embargo, la fecha se está formateando y muestra la hora y (hora estándar del este) Me gustaría que solo muestre la fecha sin la hora incluida.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Puede crear una función de formato como

 function formatDate(d) { return `${String(d.getDate()).padStart(2, '0')}/${String(d.getMonth() + 1).padStart(2, '0')}/${d.getFullYear()}`; }

Ejemplo:

 function formatDate(d) { return `${String(d.getDate()).padStart(2, '0')}/${String(d.getMonth() + 1).padStart(2, '0')}/${d.getFullYear()}`; } const i = 0; const data = [['Client', 'Recipient',,, new Date()]]; console.log('Hello '+data[i][1]+' The page for '+data[i][0]+' is due to review on '+formatDate(data[i][4])+' Please review the content and contact the team before its due date if amendments are required.');

about 4 years ago · Juan Pablo Isaza Denunciar

0

llame a esta función donde necesita la fecha formateada.

 function formatDate(date) { var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [ day, month, year].join('/'); }
about 4 years ago · Juan Pablo Isaza Denunciar

0

Si bien hay otras formas de formatear una fecha, una forma más directa, basada en Apps Script, es usar Utilities.formatDate :

 const formattedDate = Utilities.formatDate(data[i][4], Session.getTimeZone(), "dd/MM/yyyy");

Simplemente agregue esta línea justo antes de enviar el correo electrónico y reemplace data[i][4] con formattedDate en el htmlBody .

Referencia:

  • Utilities.formatDate
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda