ผมเขียนระบบที่เกี่ยวกับเวลาขึ้นมา และสร้างฟังค์ชั่น calculate เอาไว้ โดยให้ admin เป็นคนกรอกเวลา เช่น 8.00 - 20.00 ซึ่งถ้าเป็นเวลา 0.00 - 24.00 น. ก็จะเป็นปรกติของระบบ

แต่ถ้ากรอกเป็น 25.00 - 28.00 ระบบมันยังคำนวนนะครับ ว่าเป็นเวลา 3 ชม. แต่ความเป็นจริงแล้ว เวลาใน 1 วัน มันมีแค่ 24 ชั่วโมง ^_^

ปัญหาคือ ผมจะแก้ไขในส่วนนี้ได้อย่างไร ให้อาจารย์ดูท่านก็บอกให้ไปแก้ในส่วนนี้มา คนโค้ดก็ไม่ได้นึกถึงในส่วนนี้มาก่อนซะด้วย

regard
mr.man

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

jirayu Thu, 22/01/2009 - 21:27

ทำไมไม่ใช้ if ตรวจสอบแล้วหารเอาเศษเอาหว่า - -"

ถ้าเป็น php มันจะออกมาหน้าตาประมาณนี้

$time = 25.30

if($time > 24){
$time = $time%24;
}

ส่วนของ ruby ลองดัดแปลงเอาครับ ผมไม่เคยใช้ - -"

MyBlog !!!

mr_tawan Thu, 22/01/2009 - 21:47

ผมว่ากรณีนี้น่าจะเป็น Input Error มากกว่านะครับ ^^'

เช็คค่าว่าอยู่ในช่วง 0-24 หรือเปล่า ถ้าไม่ก็แสดงผลว่าอินพุตผิดพลาดน่าจะถูกกว่านะครับ ถ้าเอาไป %24 เพื่อให้ได้ค่าในช่วง 0-24 มันผิด Logic นะผมว่า มันผิดสามัญสำนึกน่ะครับ 55

ThaiGameDevX -- The First Game Developer Community in Thailand.

jirayu Thu, 22/01/2009 - 21:54

In reply to by mr_tawan

เห็น จขกท บอกว่ามันยังประมวลผลให้ เลยคิดว่าคงจะทำให้รองรับแบบนี้น่ะ - -"

ที่จริงถ้าจะให้แจ้งว่า input error ก็เปลี่ยนตรง $time = $time%24 (ส่วนที่ปรับเวลาให้เข้าห้วง 24 ชั่วโมง) ให้เปลี่ยนแจ้งว่า input error ก็ได้ครับ แหะๆ

MyBlog !!!

Sikachu Fri, 23/01/2009 - 01:34

field มันเก็บแยกกันหรือเปล่าครับ? ระหว่างเวลาเริ่มกับเวลาสิ้นสุด

แนะนำให้ใช้ Time.parse() แต่ละ field แล้วดูว่ามี exception หรือเปล่าครับ ง่ายที่สุดแล้ว

ถ้าเก็บไว้ field เดียวกันก็ใช้ time.split(/ - /) แบ่งออกมาครับ

และถ้าง่ายที่สุด ใช้ date_select ไปเลยครับ ให้เป็น drop down ไปเลย

ข้อมูลน้อยไป ตอบกว้างไปหน่อยนะครับ :D

บล็อกของผม: http://sikachu.com

poloman Fri, 23/01/2009 - 01:44

In reply to by Sikachu

ใช่ครับ ฟิลด์เก็บแยกกัน ระหว่างเริ่มต้น - สิ้นสุด

หรือผมจะใช้การ valid ดีครับ ว่าถ้ากรอกเกิน 24 ให้เด้ง alert ขึ้นมา

แบบว่า ยิ่งทำมันยิ่งตื้อครับ อยากพรีเซ้นเต็มแก่แล้วอะ