46 votes
Accepted

Magento 2 - How to add the DateTime UI Component

To add the dateTime picker you should use the next directive inside the xml file: <field name="start_date"> <argument name="data" xsi:type="array"> ...
Siarhey Uchukhlebau's user avatar
33 votes
Accepted

How to filter collection by date range on Magento 2?

Has force to seek and test several solutions I finally found ! Like I use CollectionFactory object I have to use addFieldToFilter() and not addFilter(). $slides = $this->slideCollection->...
Antoine Subit's user avatar
23 votes

Magento 2: How to get current date, date time with format in .phtml file?

protected $_date; public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $date) { $this->_date = $date; } then use like this $this->_date->date()->format('Y-...
ManiMaran A's user avatar
  • 1,136
19 votes
Accepted

Magento 2.3.0: How to add TIMESTAMP_INIT as a default value in declarative schema?

You have to need update created_datetime and updated_datetime with on_update="false" and on_update="true" in db_schema.xml app\code\Namespace\Module\etc\db_schema.xml <column xsi:type="...
Kirti Nariya's user avatar
  • 3,471
12 votes
Accepted

Magento 2: How to get current date, date time with format in .phtml file?

You can use this in phtml file : $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); $date = $...
Ashish Jagnani's user avatar
12 votes

Magento 2 Create Date with Time attribute for product

One of the possible solutions is to use Modifiers. First create Velanapps\Test\etc\adminhtml\di.xml: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Mageinn's user avatar
  • 609
9 votes
Accepted

Magento 2 backend form date time form field

Try following way: $fieldset->addField( 'time', 'date', [ 'name' => 'time', 'label' => __('Time'), 'date_format' => ...
Sohel Rana's user avatar
  • 35.9k
5 votes

Convert datetime and timezone to datetime in Magento 2

Try This protected $timezone; public function __construct( \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, ...... ) { $this->timezone = $timezone; } $dateTimeZone = $this-&...
Sanjay Gohil's user avatar
  • 2,200
4 votes

Convert datetime and timezone to datetime in Magento 2

1) We can use the PHP basic: http://php.net/manual/en/datetime.settimezone.php <?php $datetime = new DateTime('2017-01-20T13:59:19+03:00', new DateTimeZone('Europe/London')); $datetime->...
Khoa TruongDinh's user avatar
4 votes
Accepted

Database dates get stored in local timezone

Try this one to check the actual date and time as it is configured in your Magento $time = Mage::getModel('core/date')->timestamp(time()); $now = date('Y-m-d h:i:s', $time); echo $now;
PЯINCƎ's user avatar
  • 11.7k
4 votes

Magento2 convert UTC time to IST

Yes you can set timezone from admin panel. Go to Store->configuration->Genral You will find time zone according to your store you can set timezone.
Shubham Khandelwal's user avatar
3 votes

Magento 2: Filter order collection on "created_at" attribute

You can filter collection by this code $from = date("Y-m-d 00:00:00"); // current date $ordersList=Load order collection $ordersList->addFieldToFilter('created_at', array('from' => $from)); ...
Banna Online's user avatar
  • 1,069
3 votes
Accepted

date displays wrong

Times are store in the database as UTC (+0:00). When you use the $date object to render a date, it gets translated into your store's configured timezone. For example, if the date is 2017-02-15 14:37:...
Brett's user avatar
  • 1,854
3 votes

Convert datetime and timezone to datetime in Magento 2

This one works for me \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone $this->timezone = $timezone $localizedDateTimeISO = $this->timezone->date(new \DateTime($repliedAt))->...
Hiren Soni's user avatar
3 votes
Accepted

How can i create own order Time Countdown for EVERY ORDER

For your 2nd question, System > configuration > Sales > Sales emails and you can enter multiple email address in Send Order Email Copy To field.
Baby in Magento's user avatar
3 votes
Accepted

Set expiry date and save value in table magento 2?

You can use following code to get next month. $nextmonth = mktime(0, 0, 0, date("m")+1, date("d"), date("Y")); /** @var \Magento\Framework\Stdlib\DateTime\DateTime $dateTime */ $dateTime = $obj-&...
Arshad Muhammad's user avatar
3 votes

Magento 2 Data Migration time difference?

If your Magento 1 server has the time zone set to anything other than UTC, you must configure the offset to migrate timestamp fields. To transform time to a different time zone, use the Data Migration ...
Sangeeta Chandaliya's user avatar
2 votes

Magento 2 - How to add the DateTime UI Component

I hope this answer gives some idea about what you miss I added the UI component of date time field through php (it works fine) $fieldset->addField( 'event_date', 'date', [ ...
Bilal Usean's user avatar
  • 9,977
2 votes

create date and time attribute for product in magento 2

One of the possible solutions is to use Modifiers. You would need to define a modifier in Vendor\Module\etc\adminhtml\di.xml and then create the modifier itself in Vendor\Module\Ui\DataProvider\...
Mageinn's user avatar
  • 609
2 votes
Accepted

Create Date Time Instance in Magento 2

You can use php Datetime object $date = new \DateTime('now'); echo $date->format('m-d-Y h:i:s a'); Magento framework also suggests classes for doing that. You need to inject in your construct ...
Miroslav Petroff's user avatar
2 votes

Convert datetime and timezone to datetime in Magento 2

instantiate protected $_date; public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $date) { $this->_date = $date; } and use in your function $this->_date->...
Prakhar Bhardwaj's user avatar
2 votes

Convert datetime and timezone to datetime in Magento 2

$date = '2018-01-29 13:10:20'; $this->formatDate( $this->_localeDate->date(new \DateTime($date)), \IntlDateFormatter::MEDIUM, ...
Jarik Bulba's user avatar
2 votes
Accepted

DateTime UI Component - adjust the timezone

The timezone is right. The origin of the problem is the wrong timeFormat in the answer of Magento 2 - How to add the DateTime UI Component, We need change hh:mm:ss to HH:mm:ss in the UI Componet, ...
Key Shang's user avatar
  • 3,415
2 votes
Accepted

How to save local date in custom datetime field

I can see, M2 has similar function as M1 in controller class //$this->dateTimeFilter is \Magento\Framework\Stdlib\DateTime\Filter\DateTime protected function _filterPostData($data) { $...
Adarsh Khatri's user avatar
2 votes
Accepted

Display date in different languages

To format dates in other languages, you should use the setlocale() and strftime() functions. <?php setlocale(LC_TIME, "fr_FR"); // Here fr_FR is your translation locale echo strftime("%d %B, %Y"); ...
Abdul Pathan's user avatar
  • 2,802
1 vote
Accepted

how to change magento 2 date.js form file

It is better to put your custom date.js on the same path level of core date.js like this 'map': { '*': { 'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/...
fmsthird's user avatar
  • 4,592
1 vote

Get store date and time in checkout

Use this to get store date and time:- public function __construct(Context $context, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, ...) { ... $this->timezone = $timezone; ...
mansi's user avatar
  • 411
1 vote

Invalid input datetime

Kevin, its Format should be MM/DD/YYYY in data picker Then it will be work
Amit Bera's user avatar
  • 77.5k
1 vote
Accepted

Tried to implement the datetime picker magento2, but only date is coming

Same link find the solution Magento 2 Create Date with Time attribute for product I have done validation separately for this, because frontend_class is not appearing in the admin side,Magento is ...
Naveenbos's user avatar
  • 1,226
1 vote

Countdown Timer is not working in magento 2.1.7?

I have used custom countdown using jQuery, Date Format $test['date_from'] = 08/17/2017 2:52 PM $test['date_to'] = 08/26/2017 2:52 PM $microsecond=microtime(); $current_id=1; Use this code its ...
Bhavin Gehlot's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible