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.
Related
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.
I am trying to compare and check the date if it is today's date or not in a spesific program. I tried to use assertion method but when I use it the time will remain same if you try it next day. The main problem that I need to know when open a page from program It should be today's date and should be passed. if you know already anything about it please let me know also :)
Thanks yo!
Use System.DateTime.Now.ToString("yyyy-MM-dd") as one argument of the assertion. You may need to use a different format rather in the ...ToString() method. The exact format depends on how the date is shown on the screen.
This could be done using "StringAssert" to verify that your programs date string contains today's date string, while ignoring the time:
var programDateString = "7/25/2016 12:00:00"; //this is an example of your date retrieved from the application with time included
var todaysDate = System.DateTime.Today.ToShortDateString(); //short date string
StringAssert.Contains(programDateString, todaysDate);
I am creating a google calendar will contain birthdays in it. To make it automatically, I created a form and a script that would automatically create the vent and repeat it every year.
I get a problem that I just can't understand: the day and the month get inversed in the calendar.
The code is made by 2 files, one that contains the function that creates the event and the other is triggered when the form is submitted. The dates are also saved in a google spreadsheet. Here is the code:
Create the event:
function createBirthdays_ ( namedValues ) {
var cEvent = CalendarApp.getCalendarsByName( "Anniversaires CA" )[0].createAllDayEventSeries(namedValues.Nom, new Date ( namedValues.Date ), CalendarApp.newRecurrence().addYearlyRule());
}
The function that gets triggered when the form is submitted:
function onFormSubmit(e) {
createBirthdays_ ( e.namedValues );
}
I am sure it is something really simple, but I can't find it.
Might it be that in one of them you get European date format and in the other the US? There the month and day are in different order. So you might want to try to process namedValues.
I have a form, that saves date of birth in the database. This form passes three variables to php: $ayear $amonth $adate
Now I need to save these in the database in a format: 00/00/0000 (or 00/00/00, if 00/00/0000 is not supported).
I need to create a date() variable, but I dont know how. All the examles on the internet use time() or now() which are not usefull in my case. Can someone give me the right function?
Thank you for your time!
If you're using MySQL you'll want to save as YYYY-MM-DD with the field type set to date. I'd save this variables value to the database.
$birthday = implode('-', array($year, $month, $day));
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));