Jump to content

add code for today date in my php class/function

- - - - -

  • Please log in to reply
8 replies to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
Good day!

I want to know what is the syntax for date(dd-mm-yyyy) and how can I insert it to my code:

$Mail->Subject = 'Preview/' . $this->csvUploadPaymentDetails[0]['csvfilename'];


Sorry, because I'm not familiar with class and function.

i want toe result is Preview/Filename/Date/

Thank you so much

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
The formatting specifiers can be found on the main PHP manual page. PHP: date - Manual

This function may also accept a timestamp as the second parameter, in case you are required to generate a formatted date from a previous timestamp.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
How can I add this code:


$this->csvUploadPaymentDetails[0]['week_num']


with this code:


$Mail->Subject = 'Preview/' . $this->csvUploadPaymentDetails[0]['csvfilename'] .'/'.date('d-m-Y'); 


to make the subject become:

Preview/Filename/Date/Week No

Thank you

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
I would assume the same way you had concatenated the other elements.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
Is it like this:


$Mail->Subject = 'Preview/' . $this->csvUploadPaymentDetails[0]['csvfilename'] .'/'.date('d-m-Y').'/'.$this->csvUploadPaymentDetails[0]['week_num'] ; 



#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
If that is how you had wished to format the subject, then it should look like that.

I would brush up on classes and object oriented features in PHP, you likely can write buggy code if you do not understand how to work with your classes.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
thank you..so is it ok that 2 this in one property? I mean 2 this in subject?

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Of course, $this variable is a variable that accesses the current class. So your function would retrieve csvUploadPaymentDetails[0]['csvfilename'] of the current class.

csvUploadPaymentDetails[0]['csvfilename'] should simply be a string, so you can add it any way you wish (with the concatenation operator, the ".")
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#9
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
Thank you..




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users