Zend framework invalid date - zend-framework

I am using Zend framework for the site which sends email for the voucher order with a pdf attachment in the email. Everything work fine with the site but the Expiry date sending to the pdf alone have problems. I have passed the expiry date parameter from my database table values but it always takes the some default value of 1-1-1970. I have used the following set of codes for the pdf attachment with the email.
$endDate = new Zend_Date();
$endDate->set($data['voucher']['enddate']);
$endDate= $endDate->toString('dd/MM/YYYY');
//build PDF voucher attachment
$at = $this->generateVoucherPDFAttachement($recipientName, $customerName, $data['order']['msg'], $order['vouchercode'], $endDate);
$this->_helper->Mail(array(
'smile#ipressprinting.com.au' => 'Smile#iPress',
'info#ipressprinting.com.au' => 'Info#iPress',
), 'New voucher order #' . $data['order']['id'], $mailMsg, $at);

Which is the format of $data['voucher']['enddate']? You should take care of it when building a Zend_Date object, otherwise it will use an heuristic based on current locale to parse the date given.
Usually if the date comes from a db field (i.e. yyyy-mm-dd) you can build a Zend_Date in this way:
$date = new Zend_Date('2011-08-24', 'yyyy-MM-dd');
print_r($date->get(Zend_Date::DATE_FULL));

Related

How to extract year only from email date

I'm reading an entire Gmail emails (inbox/sent/trash...), and try to create folders in google drive according to dates.
So folders should be categorized like (...,2019,2020, 2021). Each folder contains all emails in this year in my Gmail.
I managed to create the folders, getting messages through using Threads, all these things works fine, but I couldn't extract the year of the message only.
As when I use Threads[0].getMessages()[0].getDate() what is returned is date and time of this message. which I can't extract the year only from it.
I tried to split the date, but this is not string.
I tried to make smth like Threads[0].getMessages()[0].getDate().getYear() it returned 120!!!
I tried to see if I can access it as an array, [index], it returned null
I tried to parse it to Date(), but I couldn't get use of it too.
Is there is anyway that allows me to extract only the year from this format.
This is part of the script where i'm trying to fetch the date I'm using.
function GetAttachmentsWithTime() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
sheet.setActiveSheet(sheet.getSheetByName('Sheet1'));
var start = 0;
var end = 10;
var filter = "has:attachment";
var threads = GmailApp.search(filter,start,end);
Logger.log(threads[0].getMessages()[0].getDate())
}
Are you using the V8 runtime?
If so, see this migration guide. It says:
In the V8 runtime, Date.prototype.getYear() returns the year minus
1900 instead as required by ECMAScript standards.
So emails from the year 2020 would return 120 (i.e. 2020 - 1900 = 120).
To fix this, use .getFullYear():
When migrating your script to V8, always use
Date.prototype.getFullYear(), which returns a four-digit year
regardless of the date.

Microsoft access change the date format from dd/m/yyyy = 28/9/2018 to dd/mm/yyyy = 28/09/2018 and its all data

i want to change the date format of my microsoft access because of im having a problem displaying the data of my program on datagridview and crystal report.because the program is supposed to read the date on dd/mm/yyyy but on my microsoft access it is format on dd/m/yyyy. is possible to change it to dd/mm/yy and all records in my database thanksss.
Date values carry no format. However, a default format - as to your system settings - is applied whenever a date value is displayed to make it human readable.
So, either change your system settings, or apply the format you prefer to the Format property of any control (textbox) where a date value is displayed: dd/mm/yyyy
How the dates are displayed in Crystal Reports is not related to VB.
I agree that whether Crystal Reports supports custom formatting and how is not a VB6 question.
As for a DataGrid, it is fairly simple:
'Reference to: Microsoft Data Formatting Object Library 6.0 (SP6)
Set StdDataFormat = New StdFormat.StdDataFormat
With StdDataFormat
.Type = fmtCustom
.Format = "dd/mm/yyyy"
End With
Set DataGrid1.DataSource = RS
Set DataGrid1.Columns(0).DataFormat = StdDataFormat

fat free framework template date formatting

I have a DateTime field in mysql. Using a .ini file with this code:
_dateformat = {0,date,custom,%m-%d-%Y}
I can change the printed format of MyDate depending on the loaded language .ini by using this in my template:
{{#_dateformat,strtotime(#MyDate) |format}}
I'm now trying to find a way to display only the full month name from that date.
I tried these options (looking at the ICU-project specs)
_monthname = {0,date,custom,%M} (up to four M's)
_monthname = {0,date,custom,%L} (up to four L's)
_monthname = {0,date,custom,%F} (displays the date in yyyy-mm-dd format)
But nothing returns the month name.
How can I display only the month name of a date, language specific, in fat free framework using the template engine?

Laravel Date calculation

I need to set end_at attribute 30 days from current date. how can i do that in laravel 4.
When I have used bellow code I am getting error saying "Class 'Date' not found"
Please help me to fix this.
$sub->end_at = new Date('+30 days');
There is no Date class in PHP, there is only a DateTime class which you could use.
But since you're using Laravel, which uses the Carbon library by default, you can use that to handle dates because it has a better API. In your case you can do this:
use Carbon\Carbon;
...
$sub->end_at = Carbon::now()->addDays(30)->toIso8601String();
If you're trying to update a Eloquent model, then you can take advantage of Eloquent's integrated date/time column handling. In your model you can add the dates property with this value:
protected $dates = ['end_at'];
and now when assigning a timestamp to the end_at column, Laravel will automatically transform and save it to the correct format in your database. So you'll only need to use this:
$sub->end_at = Carbon::now()->addDays(30);
This will return that in the format appropriate for MySQL
$sub->end_at = date('Y-m-d H:i:s', strtotime('+30 days'));

Get users current date

I need to check what’s the current date where the user is in.
I don’t need the time, just the current date.
How can i do it?
I'm using codeigniter.
Thanks.
I've managed to get the date on the client side.
My problem is that i get an error (0) when trying to parse it using strtotime.
I know that means the string is not ok but when i do an echo it displays ok(07/11/2010).
Here's the code:
javascript:
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year
HTML:
$curdate="";
$newdate = strtotime ( '-0 year' , strtotime ( $curdate ) ) ;
$curdate=date ( 'Y-m-d' , $newdate );
echo form_hidden('curdate','',$curdate);
The web server and, by extension, your application do not have this information. You have to get that input from the client side somehow. A couple of ideas come to mind:
Ask the user what time zone they're in (e.g., with a form), then calculate their date based on that.
Use some JavaScript that finds the information automatically (e.g., getTimezoneOffset()). Optionally, submit this information to your app via Ajax.