Yii Framework Forum: Showing the current system time - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Showing the current system time Rate Topic: -----

#1 User is offline   carn4ge 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 04-January 17

Posted 31 August 2017 - 12:21 PM

Hi! How do I show my current system (PC) time on a form

Right now I'm currently using a datetimepicker, I wanna try when I'm going to create something in a form the "time_start" will automatically get the time that is being used on my PC.

<?= $form->field($model, 'time_start')->widget(
                                DateTimePicker::className(), [
                                'options' => ['placeholder' => 'Render Time'],
                                'pluginOptions' => ['autoclose' => true,]
                                ]
    ); ?>


For example a basic PHP time function like this

<?php
$t=time();
echo($t . "<br>");
echo(date("Y-m-d",$t));
?>

0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,184
  • Joined: 17-January 09
  • Location:Russia

Posted 31 August 2017 - 04:14 PM

Use JavaScript.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I can work more on Yii: https://www.patreon.com/samdark
0

#3 User is offline   carn4ge 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 04-January 17

Posted 02 September 2017 - 01:20 PM

View Postsamdark, on 31 August 2017 - 04:14 PM, said:

Use JavaScript.


I tried creating a script in javascript also did some research

<script>
	var currentTime = new Date(),
      hours = currentTime.getHours(),
      minutes = currentTime.getMinutes();

	if (minutes < 10) {
	 minutes = "0" + minutes;
      
      
  }
	document.write(hours + ":" + minutes)
    var currentDate = new Date(),
      day = currentDate.getDate(),
      month = currentDate.getMonth() + 1,
      year = currentDate.getFullYear();
  document.write(day + "/" + month + "/" + year)
</script>


As of now I have done this, I only have basic knowledge in javascript how do I merge it with a php form?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users