Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Date change: +1 days, +1 month or +1 years Rate Topic   - - - - -

 
  • offex
  • Junior Member
  • Members
  • Join Date: 19-Jan 10
  • 28 posts

Posted 13 January 2012 - 09:55 PM #1

I want to display date in the future, for example +10 days or +6 month, ect.!
{$date|date_format:$settings.Appearance.date_format}

Can someone maybe help me? Thank you.
Sincerely yours,

Jacek R. // BRAUTWELT
www.brautwelt.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11456 posts

Posted 13 January 2012 - 11:01 PM #2

$date is a timestamp (I.e. Unix Timestamp - seconds since Jan 1, 1970 @ midnight).
So you would want to adjust $date by doing something like:
{math var="date" expr="x+y" x=$date y=$smarty.const.SECONDS_IN_DAY}
to get 1 day ahead... Put this above your {$date|format.......} line.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • offex
  • Junior Member
  • Members
  • Join Date: 19-Jan 10
  • 28 posts

Posted 14 January 2012 - 10:05 AM #3

$date is a timestamp (I.e. Unix Timestamp - seconds since Jan 1, 1970 @ midnight).
So you would want to adjust $date by doing something like:
{math var="date" expr="x+y" x=$date y=$smarty.const.SECONDS_IN_DAY}
to get 1 day ahead... Put this above your {$date|format.......} line.

Thank you for your answer, but I unfortunately do not come forward.
Can you explain more precisely, where will I use. For example, 14 days (14 * 60 * 60 * 24) (days * seconds * minutes * hours)

{math var="date" expr="x+y" x=$date y=$smarty.const.SECONDS_IN_DAY} 
{$date|date_format:$settings.Appearance.date_format}
Here is a error"... error: missing parameter equation"
Thanks
Sincerely yours,

Jacek R. // BRAUTWELT
www.brautwelt.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11456 posts

Posted 14 January 2012 - 07:31 PM #4

Sorry, was responding off the top of my head. Was hoping you'd take it as a concept rather than an absolute solution. Suggest you search for the Smarty manual to get the attributes correct for the 'math' function and I'd assume from the error that 'expr' should be 'equation'.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • offex
  • Junior Member
  • Members
  • Join Date: 19-Jan 10
  • 28 posts

Posted 14 January 2012 - 07:56 PM #5

Perhaps I was not very evident. I would like to send in your addon "Auto Mailer" for customers with a date (+ "1 .." days, weeks).
I hope you understand me better now.
Can you help me! Thank you!
Sincerely yours,

Jacek R. // BRAUTWELT
www.brautwelt.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11456 posts

Posted 15 January 2012 - 07:09 AM #6

Actually, I have no idea what you want now at all.... My Auto Mail addon wasn't even mentioned before this.

If you want to set a date for sometime in the future and have that displayed in a date format, there are as many ways to do this as there are programmers. What I would do then is:
{assign var="my_tomorrow" value="tomorrow"|strtotime|date_format:$settings.Appearance.date_format}

The PHP strtotime() function will parse almost any string you can give it into a timestamp. I.e. "yesterday", "15th of next month", "2 days", etc.... Google it for info.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • offex
  • Junior Member
  • Members
  • Join Date: 19-Jan 10
  • 28 posts

Posted 15 January 2012 - 04:05 PM #7

Thank for your help. So simple and yet so difficult. I have installed in your auto-mailer and now works well. Thank you again. For anyone looking for that too, this is the code!
{assign var="my_time" value="+2 days"|strtotime|date_format:$settings.Appearance.date_format}
{$my_time|date_format:$settings.Appearance.date_format}</h3>
Only <<< "2 days">>>simply change "next week" , "2 month" or "2 days" etc.
Sincerely yours,

Jacek R. // BRAUTWELT
www.brautwelt.com

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11456 posts

Posted 15 January 2012 - 08:14 PM #8

You don't need your second line since {$my_time} is already in the date format set for $settings.Appearance.date_format.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.